Fix recompilation under jsd and simplify frame searching (bug 609363, r=lw, a=b7+).
[mozilla-central.git] / xpcom / threads / nsIThreadInternal.idl
blobd8f430c60d4325f9b7ed961d87a5581e2d0a41e9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is Mozilla code.
18 * The Initial Developer of the Original Code is Google Inc.
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Darin Fisher <darin@meer.net>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsIThread.idl"
41 interface nsIThreadObserver;
42 interface nsIThreadEventFilter;
44 /**
45 * The XPCOM thread object implements this interface, which allows a consumer
46 * to observe dispatch activity on the thread.
48 [scriptable, uuid(f89b5063-b06d-42f8-bf23-4dfcf2d80d6a)]
49 interface nsIThreadInternal : nsIThread
51 /**
52 * Get/set the current thread observer (may be null). This attribute may be
53 * read from any thread, but must only be set on the thread corresponding to
54 * this thread object. The observer will be released on the thread
55 * corresponding to this thread object after all other events have been
56 * processed during a call to Shutdown.
58 attribute nsIThreadObserver observer;
60 /**
61 * This method causes any events currently enqueued on the thread to be
62 * suppressed until PopEventQueue is called. Additionally, any new events
63 * dispatched to the thread will only be processed if they are accepted by
64 * the given filter. If the filter is null, then new events are accepted.
65 * Calls to PushEventQueue may be nested and must each be paired with a call
66 * to PopEventQueue in order to restore the original state of the thread.
68 * @param filter
69 * The thread event filter to apply to dispatched events, or null to accept
70 * all dispatched events.
72 void pushEventQueue(in nsIThreadEventFilter filter);
74 /**
75 * Revert a call to PushEventQueue. When an event queue is popped, any
76 * events remaining in the queue are appended to the elder queue.
78 void popEventQueue();
81 /**
82 * This interface provides the observer with hooks to implement a layered
83 * event queue. For example, it is possible to overlay processing events
84 * for a GUI toolkit on top of the events for a thread:
86 * var NativeQueue;
87 * Observer = {
88 * onDispatchedEvent(thread) {
89 * NativeQueue.signal();
90 * }
91 * onProcessNextEvent(thread, mayWait, recursionDepth) {
92 * if (NativeQueue.hasNextEvent())
93 * NativeQueue.processNextEvent();
94 * while (mayWait && !thread.hasPendingEvent()) {
95 * NativeQueue.wait();
96 * NativeQueue.processNextEvent();
97 * }
98 * }
99 * };
101 * NOTE: The implementation of this interface must be threadsafe.
103 * NOTE: It is valid to change the thread's observer during a call to an
104 * observer method.
106 [scriptable, uuid(81D0B509-F198-4417-8020-08EB4271491F)]
107 interface nsIThreadObserver : nsISupports
110 * This method is called after an event has been dispatched to the thread.
111 * This method may be called from any thread.
113 * @param thread
114 * The thread where the event is being dispatched.
116 void onDispatchedEvent(in nsIThreadInternal thread);
119 * This method is called (from nsIThread::ProcessNextEvent) before an event
120 * is processed. This method is only called on the target thread.
122 * @param thread
123 * The thread being asked to process another event.
124 * @param mayWait
125 * Indicates whether or not the method is allowed to block the calling
126 * thread. For example, this parameter is false during thread shutdown.
127 * @param recursionDepth
128 * Indicates the number of calls to ProcessNextEvent on the call stack in
129 * addition to the current call.
131 void onProcessNextEvent(in nsIThreadInternal thread, in boolean mayWait,
132 in unsigned long recursionDepth);
135 * This method is called (from nsIThread::ProcessNextEvent) after an event
136 * is processed. This method is only called on the target thread.
138 * @param thread
139 * The thread that processed another event.
140 * @param recursionDepth
141 * Indicates the number of calls to ProcessNextEvent on the call stack in
142 * addition to the current call.
144 void afterProcessNextEvent(in nsIThreadInternal thread,
145 in unsigned long recursionDepth);
149 * Interface passed to the nsIThreadInternal::PushEventQueue method.
151 [scriptable, uuid(a0605c0b-17f5-4681-b8cd-a1cd75d42559)]
152 interface nsIThreadEventFilter : nsISupports
155 * This method is called to determine whether or not an event may be accepted
156 * by a "nested" event queue (see nsIThreadInternal::PushEventQueue).
158 * @param event
159 * The event being dispatched.
161 * WARNING: This method must not make any calls on the thread object.
163 [notxpcom] boolean acceptEvent(in nsIRunnable event);