1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/threads/nsIEventTarget.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsISupports.idl" 1.11 + 1.12 +interface nsIRunnable; 1.13 + 1.14 +[scriptable, uuid(4e8febe4-6631-49dc-8ac9-308c1cb9b09c)] 1.15 +interface nsIEventTarget : nsISupports 1.16 +{ 1.17 + /** 1.18 + * Dispatch an event to this event target. This function may be called from 1.19 + * any thread, and it may be called re-entrantly. 1.20 + * 1.21 + * @param event 1.22 + * The event to dispatch. 1.23 + * @param flags 1.24 + * The flags modifying event dispatch. The flags are described in detail 1.25 + * below. 1.26 + * 1.27 + * @throws NS_ERROR_INVALID_ARG 1.28 + * Indicates that event is null. 1.29 + * @throws NS_ERROR_UNEXPECTED 1.30 + * Indicates that the thread is shutting down and has finished processing 1.31 + * events, so this event would never run and has not been dispatched. 1.32 + */ 1.33 + void dispatch(in nsIRunnable event, in unsigned long flags); 1.34 + 1.35 + /** 1.36 + * This flag specifies the default mode of event dispatch, whereby the event 1.37 + * is simply queued for later processing. When this flag is specified, 1.38 + * dispatch returns immediately after the event is queued. 1.39 + */ 1.40 + const unsigned long DISPATCH_NORMAL = 0; 1.41 + 1.42 + /** 1.43 + * This flag specifies the synchronous mode of event dispatch, in which the 1.44 + * dispatch method does not return until the event has been processed. 1.45 + * 1.46 + * NOTE: passing this flag to dispatch may have the side-effect of causing 1.47 + * other events on the current thread to be processed while waiting for the 1.48 + * given event to be processed. 1.49 + */ 1.50 + const unsigned long DISPATCH_SYNC = 1; 1.51 + 1.52 + /** 1.53 + * Check to see if this event target is associated with the current thread. 1.54 + * 1.55 + * @returns 1.56 + * A boolean value that if "true" indicates that events dispatched to this 1.57 + * event target will run on the current thread (i.e., the thread calling 1.58 + * this method). 1.59 + */ 1.60 + boolean isOnCurrentThread(); 1.61 +}; 1.62 + 1.63 +%{C++ 1.64 +// convenient aliases: 1.65 +#define NS_DISPATCH_NORMAL nsIEventTarget::DISPATCH_NORMAL 1.66 +#define NS_DISPATCH_SYNC nsIEventTarget::DISPATCH_SYNC 1.67 +%}