xpcom/threads/nsIThreadManager.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/threads/nsIThreadManager.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     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 +[ptr] native PRThread(PRThread);
    1.13 +
    1.14 +interface nsIThread;
    1.15 +
    1.16 +/**
    1.17 + * An interface for creating and locating nsIThread instances.
    1.18 + */
    1.19 +[scriptable, uuid(1be89eca-e2f7-453b-8d38-c11ba247f6f3)]
    1.20 +interface nsIThreadManager : nsISupports
    1.21 +{
    1.22 +  /**
    1.23 +   * Default number of bytes reserved for a thread's stack, if no stack size
    1.24 +   * is specified in newThread(). 0 means use platform default.
    1.25 +   */
    1.26 +  const unsigned long DEFAULT_STACK_SIZE = 0;
    1.27 +
    1.28 +  /**
    1.29 +   * Create a new thread (a global, user PRThread).
    1.30 +   *
    1.31 +   * @param creationFlags
    1.32 +   *   Reserved for future use.  Pass 0.
    1.33 +   * @param stackSize
    1.34 +   *   Number of bytes to reserve for the thread's stack.
    1.35 +   *
    1.36 +   * @returns
    1.37 +   *   The newly created nsIThread object.
    1.38 +   */
    1.39 +  nsIThread newThread(in unsigned long creationFlags, [optional] in unsigned long stackSize);
    1.40 +
    1.41 +  /**
    1.42 +   * Get the nsIThread object (if any) corresponding to the given PRThread.
    1.43 +   * This method returns null if there is no corresponding nsIThread.
    1.44 +   *
    1.45 +   * @param prthread
    1.46 +   *   The PRThread of the nsIThread being requested.
    1.47 +   *
    1.48 +   * @returns
    1.49 +   *   The nsIThread object corresponding to the given PRThread or null if no
    1.50 +   *   such nsIThread exists.
    1.51 +   */
    1.52 +  [noscript] nsIThread getThreadFromPRThread(in PRThread prthread);
    1.53 +
    1.54 +  /**
    1.55 +   * Get the main thread.
    1.56 +   */
    1.57 +  readonly attribute nsIThread mainThread;
    1.58 +
    1.59 +  /**
    1.60 +   * Get the current thread.  If the calling thread does not already have a
    1.61 +   * nsIThread associated with it, then a new nsIThread will be created and
    1.62 +   * associated with the current PRThread.
    1.63 +   */
    1.64 +  readonly attribute nsIThread currentThread;
    1.65 +
    1.66 +  /**
    1.67 +   * This attribute is true if the calling thread is the main thread of the
    1.68 +   * application process.
    1.69 +   */
    1.70 +  readonly attribute boolean isMainThread;
    1.71 +};

mercurial