nsIThreadObserver 编辑
The nsIThreadObserver
interface may be implemented to let an observer implement a layered event queue.
The implementation of this interface must be thread safe.
xpcom/threads/nsIThreadInternal.idl
Scriptable Please add a summary to this article. Last changed in Gecko 1.9 (Firefox 3)Inherits from: nsISupports
Method overview
void afterProcessNextEvent(in nsIThreadInternal thread, in unsigned long recursionDepth); |
void onDispatchedEvent(in nsIThreadInternal thread); |
void onProcessNextEvent(in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth); |
Methods
afterProcessNextEvent()
Called by the nsIThread
method nsIThread.ProcessNextEvent()
after an event is processed. This method is only called on the target thread.
void afterProcessNextEvent( in nsIThreadInternal thread, in unsigned long recursionDepth );
Parameters
thread
- The
nsIThread
on which the event was processed. recursionDepth
- The number of calls to
nsIThread.ProcessNextEvent()
on the call stack in addition to the current call.
onDispatchedEvent()
Called after an event has been dispatched to the thread. This method may be called from any thread.
Note: It is valid to change the thread's observer during a call to this method.void onDispatchedEvent( in nsIThreadInternal thread );
Parameters
thread
- The
nsIThread
on which the event was dispatched.
onProcessNextEvent()
Called by the nsIThread
method nsIThread.ProcessNextEvent()
before an event is processed. This method is only called on the target thread.
It is valid to change the thread\'s observer during a call to this method.
void onProcessNextEvent( in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth );
Parameters
thread
- The
nsIThread
on which the event is going to be processed. mayWait
true
if the method is allowed to block the calling thread. This parameter will befalse
during thread shutdown.recursionDepth
- The number of calls to
nsIThread.ProcessNextEvent()
on the call stack in addition to the current call.
Example
It is possible to overlay processing events for a GUI toolkit on top of the events for a thread:
var NativeQueue; Observer = { onDispatchedEvent(thread) { NativeQueue.signal(); } onProcessNextEvent(thread, mayWait, recursionDepth) { if (NativeQueue.hasNextEvent()) { NativeQueue.processNextEvent(); } while (mayWait && !thread.hasPendingEvent()) { NativeQueue.wait(); NativeQueue.processNextEvent(); } } };
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论