xpcom/threads/nsIThread.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "nsIEventTarget.idl"
michael@0 8
michael@0 9 [ptr] native PRThread(PRThread);
michael@0 10
michael@0 11 /**
michael@0 12 * This interface provides a high-level abstraction for an operating system
michael@0 13 * thread.
michael@0 14 *
michael@0 15 * Threads have a built-in event queue, and a thread is an event target that
michael@0 16 * can receive nsIRunnable objects (events) to be processed on the thread.
michael@0 17 *
michael@0 18 * See nsIThreadManager for the API used to create and locate threads.
michael@0 19 */
michael@0 20 [scriptable, uuid(9c889946-a73a-4af3-ae9a-ea64f7d4e3ca)]
michael@0 21 interface nsIThread : nsIEventTarget
michael@0 22 {
michael@0 23 /**
michael@0 24 * @returns
michael@0 25 * The NSPR thread object corresponding to this nsIThread.
michael@0 26 */
michael@0 27 [noscript] readonly attribute PRThread PRThread;
michael@0 28
michael@0 29 /**
michael@0 30 * Shutdown the thread. This method prevents further dispatch of events to
michael@0 31 * the thread, and it causes any pending events to run to completion before
michael@0 32 * the thread joins (see PR_JoinThread) with the current thread. During this
michael@0 33 * method call, events for the current thread may be processed.
michael@0 34 *
michael@0 35 * This method MAY NOT be executed from the thread itself. Instead, it is
michael@0 36 * meant to be executed from another thread (usually the thread that created
michael@0 37 * this thread or the main application thread). When this function returns,
michael@0 38 * the thread will be shutdown, and it will no longer be possible to dispatch
michael@0 39 * events to the thread.
michael@0 40 *
michael@0 41 * @throws NS_ERROR_UNEXPECTED
michael@0 42 * Indicates that this method was erroneously called when this thread was
michael@0 43 * the current thread, that this thread was not created with a call to
michael@0 44 * nsIThreadManager::NewThread, or if this method was called more than once
michael@0 45 * on the thread object.
michael@0 46 */
michael@0 47 void shutdown();
michael@0 48
michael@0 49 /**
michael@0 50 * This method may be called to determine if there are any events ready to be
michael@0 51 * processed. It may only be called when this thread is the current thread.
michael@0 52 *
michael@0 53 * Because events may be added to this thread by another thread, a "false"
michael@0 54 * result does not mean that this thread has no pending events. It only
michael@0 55 * means that there were no pending events when this method was called.
michael@0 56 *
michael@0 57 * @returns
michael@0 58 * A boolean value that if "true" indicates that this thread has one or
michael@0 59 * more pending events.
michael@0 60 *
michael@0 61 * @throws NS_ERROR_UNEXPECTED
michael@0 62 * Indicates that this method was erroneously called when this thread was
michael@0 63 * not the current thread.
michael@0 64 */
michael@0 65 boolean hasPendingEvents();
michael@0 66
michael@0 67 /**
michael@0 68 * Process the next event. If there are no pending events, then this method
michael@0 69 * may wait -- depending on the value of the mayWait parameter -- until an
michael@0 70 * event is dispatched to this thread. This method is re-entrant but may
michael@0 71 * only be called if this thread is the current thread.
michael@0 72 *
michael@0 73 * @param mayWait
michael@0 74 * A boolean parameter that if "true" indicates that the method may block
michael@0 75 * the calling thread to wait for a pending event.
michael@0 76 *
michael@0 77 * @returns
michael@0 78 * A boolean value that if "true" indicates that an event was processed.
michael@0 79 *
michael@0 80 * @throws NS_ERROR_UNEXPECTED
michael@0 81 * Indicates that this method was erroneously called when this thread was
michael@0 82 * not the current thread.
michael@0 83 */
michael@0 84 boolean processNextEvent(in boolean mayWait);
michael@0 85 };

mercurial