xpcom/threads/nsIEventTarget.idl

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:db8270812821
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 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "nsISupports.idl"
8
9 interface nsIRunnable;
10
11 [scriptable, uuid(4e8febe4-6631-49dc-8ac9-308c1cb9b09c)]
12 interface nsIEventTarget : nsISupports
13 {
14 /**
15 * Dispatch an event to this event target. This function may be called from
16 * any thread, and it may be called re-entrantly.
17 *
18 * @param event
19 * The event to dispatch.
20 * @param flags
21 * The flags modifying event dispatch. The flags are described in detail
22 * below.
23 *
24 * @throws NS_ERROR_INVALID_ARG
25 * Indicates that event is null.
26 * @throws NS_ERROR_UNEXPECTED
27 * Indicates that the thread is shutting down and has finished processing
28 * events, so this event would never run and has not been dispatched.
29 */
30 void dispatch(in nsIRunnable event, in unsigned long flags);
31
32 /**
33 * This flag specifies the default mode of event dispatch, whereby the event
34 * is simply queued for later processing. When this flag is specified,
35 * dispatch returns immediately after the event is queued.
36 */
37 const unsigned long DISPATCH_NORMAL = 0;
38
39 /**
40 * This flag specifies the synchronous mode of event dispatch, in which the
41 * dispatch method does not return until the event has been processed.
42 *
43 * NOTE: passing this flag to dispatch may have the side-effect of causing
44 * other events on the current thread to be processed while waiting for the
45 * given event to be processed.
46 */
47 const unsigned long DISPATCH_SYNC = 1;
48
49 /**
50 * Check to see if this event target is associated with the current thread.
51 *
52 * @returns
53 * A boolean value that if "true" indicates that events dispatched to this
54 * event target will run on the current thread (i.e., the thread calling
55 * this method).
56 */
57 boolean isOnCurrentThread();
58 };
59
60 %{C++
61 // convenient aliases:
62 #define NS_DISPATCH_NORMAL nsIEventTarget::DISPATCH_NORMAL
63 #define NS_DISPATCH_SYNC nsIEventTarget::DISPATCH_SYNC
64 %}

mercurial