Bug 1688832: part 5) Add `static` `AccessibleCaretManager::GetSelection`, `::GetFrame...
[gecko.git] / xpcom / threads / nsIDirectTaskDispatcher.idl
blob2729ddb7dc3786aef295b0c2cf2720c6e25f358f
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/. */
7 #include "nsIRunnable.idl"
9 %{C++
10 #include "mozilla/AlreadyAddRefed.h"
13 native alreadyAddRefed_nsIRunnable(already_AddRefed<nsIRunnable>);
16 * The primary use of this interface is to allow any nsISerialEventTarget to
17 * provide Direct Task dispatching which is similar (but not identical to) the
18 * microtask semantics of JS promises.
19 * New direct task may be dispatched when a current direct task is running. In
20 * which case they will be run in FIFO order.
22 [builtinclass, uuid(e05bf0fe-94b7-4e28-8462-a8368da9c136)]
23 interface nsIDirectTaskDispatcher : nsISupports
25 /**
26 * Dispatch an event for the nsISerialEventTarget, using the direct task
27 * queue.
29 * This function must be called from the same nsISerialEventTarget
30 * implementing direct task dispatching.
32 * @param event
33 * The alreadyAddRefed<> event to dispatch.
36 [noscript] void dispatchDirectTask(in alreadyAddRefed_nsIRunnable event);
38 /**
39 * Synchronously run any pending direct tasks queued.
41 [noscript] void drainDirectTasks();
43 /**
44 * Returns true if any direct tasks are pending.
46 [noscript] bool haveDirectTasks();
48 %{C++
49 // Infallible version of the above. Will assert that it is successful.
50 bool HaveDirectTasks() {
51 bool value = false;
52 MOZ_ALWAYS_SUCCEEDS(HaveDirectTasks(&value));
53 return value;