272
edits
Line 158: | Line 158: | ||
Development is occuring on the THREADS_20060213_BRANCH. See also {{bug|326273}}. | Development is occuring on the THREADS_20060213_BRANCH. See also {{bug|326273}}. | ||
== Comments | == Comments == | ||
=== biesi: === | |||
* What happens if shutdown is called while a task is being processed? I assume that this task will be processed to its end, no further tasks are accepted, and then the thread is shut down. right? | * What happens if shutdown is called while a task is being processed? I assume that this task will be processed to its end, no further tasks are accepted, and then the thread is shut down. right? | ||
** What happens to tasks that were already dispatched to this thread, but not run? | ** What happens to tasks that were already dispatched to this thread, but not run? | ||
Line 164: | Line 166: | ||
* Who is expected to call runNextTask? | * Who is expected to call runNextTask? | ||
=== | ==== darin: ==== | ||
* When asked to shutdown, a thread would finish dispatching all queued tasks, and refuse to accept any new tasks. Once all queued tasks run to completion, the thread would terminate. This is consistent with how event queues work today. | * When asked to shutdown, a thread would finish dispatching all queued tasks, and refuse to accept any new tasks. Once all queued tasks run to completion, the thread would terminate. This is consistent with how event queues work today. | ||
* If you are sync dispatching, then it is necessary to pump events on the calling thread or else you could end up in a dead-lock situation. For example, if thread A sync dispatches a task to thread B, which cannot complete its job without dispatching a task back to thread A, then the system will dead-lock unless thread A continues to dispatch pending tasks. | * If you are sync dispatching, then it is necessary to pump events on the calling thread or else you could end up in a dead-lock situation. For example, if thread A sync dispatches a task to thread B, which cannot complete its job without dispatching a task back to thread A, then the system will dead-lock unless thread A continues to dispatch pending tasks. | ||
* runNextTask may be called by anybody that wishes to implement the concept of a "modal event loop." For example, XMLHttpRequest (in sync configuration) would sit in a loop calling runNextTask while waiting for the underlying HTTP transaction to complete. The key difference between runNextTask and nsIEventQueue::processPendingEvents is that runNextTask, when called on the UI thread, will process UI events as well. And, it will also wait (block the thread of execution) if there are no UI events or pending tasks. | * runNextTask may be called by anybody that wishes to implement the concept of a "modal event loop." For example, XMLHttpRequest (in sync configuration) would sit in a loop calling runNextTask while waiting for the underlying HTTP transaction to complete. The key difference between runNextTask and nsIEventQueue::processPendingEvents is that runNextTask, when called on the UI thread, will process UI events as well. And, it will also wait (block the thread of execution) if there are no UI events or pending tasks. |
edits