XPCOM:nsIThreadManager: Difference between revisions

Jump to navigation Jump to search
m
Line 281: Line 281:


==== darin: ====
==== 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 events, and refuse to accept any new events.  Once all queued events 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 an event to thread B, which cannot complete its job without dispatching an event back to thread A, then the system will dead-lock unless thread A continues to dispatch pending events.
* 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.
* <code>ProcessNextEvent</code> 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 <code>ProcessNextEvent</code> while waiting for the underlying HTTP transaction to complete.  The key difference between <code>ProcessNextEvent</code> and <code>nsIEventQueue::ProcessPendingEvents</code> is that <code>ProcessNextEvent</code>, 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 <code>nsIRunnable</code> events.
272

edits

Navigation menu