xpcom/threads/nsIThread.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/threads/nsIThread.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     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 "nsIEventTarget.idl"
    1.11 +
    1.12 +[ptr] native PRThread(PRThread);
    1.13 +
    1.14 +/**
    1.15 + * This interface provides a high-level abstraction for an operating system
    1.16 + * thread.
    1.17 + *
    1.18 + * Threads have a built-in event queue, and a thread is an event target that
    1.19 + * can receive nsIRunnable objects (events) to be processed on the thread.
    1.20 + *
    1.21 + * See nsIThreadManager for the API used to create and locate threads.
    1.22 + */
    1.23 +[scriptable, uuid(9c889946-a73a-4af3-ae9a-ea64f7d4e3ca)]
    1.24 +interface nsIThread : nsIEventTarget
    1.25 +{
    1.26 +  /**
    1.27 +   * @returns
    1.28 +   *   The NSPR thread object corresponding to this nsIThread.
    1.29 +   */
    1.30 +  [noscript] readonly attribute PRThread PRThread;
    1.31 +
    1.32 +  /**
    1.33 +   * Shutdown the thread.  This method prevents further dispatch of events to
    1.34 +   * the thread, and it causes any pending events to run to completion before
    1.35 +   * the thread joins (see PR_JoinThread) with the current thread.  During this
    1.36 +   * method call, events for the current thread may be processed.
    1.37 +   *
    1.38 +   * This method MAY NOT be executed from the thread itself.  Instead, it is
    1.39 +   * meant to be executed from another thread (usually the thread that created
    1.40 +   * this thread or the main application thread).  When this function returns,
    1.41 +   * the thread will be shutdown, and it will no longer be possible to dispatch
    1.42 +   * events to the thread.
    1.43 +   *
    1.44 +   * @throws NS_ERROR_UNEXPECTED
    1.45 +   *   Indicates that this method was erroneously called when this thread was
    1.46 +   *   the current thread, that this thread was not created with a call to
    1.47 +   *   nsIThreadManager::NewThread, or if this method was called more than once
    1.48 +   *   on the thread object.
    1.49 +   */
    1.50 +  void shutdown();
    1.51 +
    1.52 +  /**
    1.53 +   * This method may be called to determine if there are any events ready to be
    1.54 +   * processed.  It may only be called when this thread is the current thread.
    1.55 +   *
    1.56 +   * Because events may be added to this thread by another thread, a "false"
    1.57 +   * result does not mean that this thread has no pending events.  It only
    1.58 +   * means that there were no pending events when this method was called.
    1.59 +   *
    1.60 +   * @returns
    1.61 +   *   A boolean value that if "true" indicates that this thread has one or
    1.62 +   *   more pending events.
    1.63 +   *
    1.64 +   * @throws NS_ERROR_UNEXPECTED
    1.65 +   *   Indicates that this method was erroneously called when this thread was
    1.66 +   *   not the current thread.
    1.67 +   */
    1.68 +  boolean hasPendingEvents();
    1.69 +
    1.70 +  /**
    1.71 +   * Process the next event.  If there are no pending events, then this method
    1.72 +   * may wait -- depending on the value of the mayWait parameter -- until an
    1.73 +   * event is dispatched to this thread.  This method is re-entrant but may
    1.74 +   * only be called if this thread is the current thread.
    1.75 +   *
    1.76 +   * @param mayWait
    1.77 +   *   A boolean parameter that if "true" indicates that the method may block
    1.78 +   *   the calling thread to wait for a pending event.
    1.79 +   *
    1.80 +   * @returns
    1.81 +   *   A boolean value that if "true" indicates that an event was processed.
    1.82 +   *
    1.83 +   * @throws NS_ERROR_UNEXPECTED
    1.84 +   *   Indicates that this method was erroneously called when this thread was
    1.85 +   *   not the current thread.
    1.86 +   */
    1.87 +  boolean processNextEvent(in boolean mayWait);
    1.88 +};

mercurial