gecko-dev/xpcom/threads/nsIThread.idl

68 строки
2.2 KiB
Plaintext

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsISupports.idl"
%{C++
#include "prthread.h"
%}
interface nsIRunnable;
native PRThreadPriority(PRThreadPriority);
native PRThreadScope(PRThreadScope);
native PRThreadState(PRThreadState);
[ptr] native PRThread(PRThread);
[scriptable, uuid(6be5e380-6886-11d3-9382-00104ba0fd40)]
interface nsIThread : nsISupports
{
void Join();
void Interrupt();
attribute PRThreadPriority Priority;
readonly attribute PRThreadScope Scope;
readonly attribute PRThreadState State;
[noscript] PRThread GetPRThread();
%{C++
// returns the nsIThread for the current thread:
static NS_COM nsresult GetCurrent(nsIThread* *result);
// returns the nsIThread for an arbitrary PRThread:
static NS_COM nsresult GetIThread(PRThread* prthread, nsIThread* *result);
// initializes the "main" thread (really, just saves the current thread
// at time of calling. meant to be called once at app startup, in lieu
// of proper static initializers, to save the primordial thread
// for later recall.)
static NS_COM nsresult SetMainThread();
// return the "main" thread
static NS_COM nsresult GetMainThread(nsIThread **result);
%}
};
%{C++
extern NS_COM nsresult
NS_NewThread(nsIThread* *result,
nsIRunnable* runnable,
PRUint32 stackSize = 0,
PRThreadPriority priority = PR_PRIORITY_NORMAL,
PRThreadScope scope = PR_GLOBAL_THREAD,
PRThreadState state = PR_JOINABLE_THREAD);
%}