We should be able to add runnable tasks, i.e. objects that define a function. These tasks should be processed in batches of n tasks.
Proposed solution: Add basic methods for task handling to oo.Worker: pushTask(), popTask(), peekTask(), numOfTasks.
Add TaskQueue interface which allows to enqueueTasks(tasks). Then you can dequeueTasks(size) and processTasks(tasks) in a batch, which returns a Promise, since the tasks you be asynchronious. Implement TaskQueue in oo.Worker.
We should be able to add runnable tasks, i.e. objects that define a function. These tasks should be processed in batches of n tasks.
Proposed solution: Add basic methods for task handling to
oo.Worker
:pushTask()
,popTask()
,peekTask()
,numOfTasks
.Add
TaskQueue
interface which allows toenqueueTasks(tasks)
. Then you candequeueTasks(size)
andprocessTasks(tasks)
in a batch, which returns aPromise
, since the tasks you be asynchronious. ImplementTaskQueue
inoo.Worker
.Task
itself defines aTaskAction
that accepts aTaskActionDone
callback for synchronious execution.