Multithreading pool made for Roblox.
For my use case, I need to queue many tasks with the ability to control the number of actors. So, I made this library which will queue tasks that use the same function and then get executed by a free actor.
local threadpool = ThreadPool.CreateThreadPool(threads, modulescript, sharedTable, callbackFunction)
- threads: number of actors created.
- modulescript: modulescript that will be required and used to execute tasks under actors.
- sharedTable: Global state table that all actors can access.
- callbackFunction: Returned values from actors can be recieved here.
threadpool:QueueTask(tuple)
- tuple: Any number of arguments that will be recieved by the given modulescript, which is bound to the actor.
threadpool:Join()
Yields the current thread until all queued tasks have been executed by the actors.
threadpool:Destroy()
Waits for all queued tasks to finish before destroying the threadpool object.
threadpool:ForceDestroy()
Destroys the threadpool object.