-
Notifications
You must be signed in to change notification settings - Fork 21
TaskQueue
Yoichiro Tanaka edited this page Dec 28, 2015
·
5 revisions
This Class provides you an ability of a Queue Mechanism. You can register a new task, and the registered tasks will be executed sequentially.
Actually, this is not a completed queue. Because, you must call shiftAndConsumeTask() function to execute a next task like "non-preemptive multitasking".
var taskQueue = new TaskQueue();
var func = function() {...};
taskQueue.addTask(func);
If the queue size was empty at registering above, the registered task will be called after 10ms.
You must call shiftAndConsumeTask() function to shift the executed task and to execute the next task.
var func = function() {
...
taskQueue.shiftAndConsumeTask();
};
taskQueue.addTask(func);
chrome.fileSystemProvider.on***Requested.addListener(
function(options, successCallback, errorCallback) { <- createEventHandler()
taskQueue.add(function() { <- prepare()
...
taskQueue.shiftAndConsumeTask();
});
}
);