Taskwork
Efficient multi-threaded task scheduler for the browser using generic re-usable WebWorkers.
Taskwork
is a task scheduler that is able to delegate tasks to WebWorkers. These WebWorkers are special in the sense that they are able to execute and return the results from arbitrary tasks send to them. At the start of the application a fixed amount of threads are spawned and re-used throughout the lifetime of the application. This has the advantage of paying the spawn-cost of WebWorkers (~45 ms
) and the overhead of spawning only once.
Another feature of Taskwork
is the ability to schedule a task with a certain priority. By automatically min-sorting the task queue based on priority we can make sure that tasks with the highest priority are executed first. This is important because the goal is to stay within the frameTarget (by default 60 fps)
frame budget. Taskwork
internally checks wether there is enough time left in the frame to run a task and automatically defers it to the next frame if there is not.
Status
UNSTABLE, IN-PROGRESS
ONLY SUPPORTED IN BROWSER
Installation
Make sure you have Node.js installed.
$ npm install taskwork
Usage
// Priorities is just an enum with default levels, you can use your own; // Any function, sync or async (this will be serialized and executed inside of a WebWorker); ; ;
Licence
My work is released under the MIT license.