VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/pprthred.h@ 101875

Last change on this file since 101875 was 101776, checked in by vboxsync, 15 months ago

libs/xpcom: Remove prthinfo which isn't used, bugref:10545

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.7 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef pprthred_h___
39#define pprthred_h___
40
41/*
42** API for PR private functions. These calls are to be used by internal
43** developers only.
44*/
45#include "nspr.h"
46
47#if defined(XP_OS2)
48#define INCL_DOS
49#define INCL_DOSERRORS
50#define INCL_WIN
51#include <os2.h>
52#endif
53
54#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
55#define PR_AttachThread VBoxNsprPR_AttachThread
56#define PR_DetachThread VBoxNsprPR_DetachThread
57#define PR_GetThreadID VBoxNsprPR_GetThreadID
58#define PR_SetThreadDumpProc VBoxNsprPR_SetThreadDumpProc
59#define PR_GetThreadAffinityMask VBoxNsprPR_GetThreadAffinityMask
60#define PR_SetThreadAffinityMask VBoxNsprPR_SetThreadAffinityMask
61#define PR_SetCPUAffinityMask VBoxNsprPR_SetCPUAffinityMask
62#define PR_ShowStatus VBoxNsprPR_ShowStatus
63#define PR_SetThreadRecycleMode VBoxNsprPR_SetThreadRecycleMode
64#define PR_CreateThreadGCAble VBoxNsprPR_CreateThreadGCAble
65#define PR_AttachThreadGCAble VBoxNsprPR_AttachThreadGCAble
66#define PR_SetThreadGCAble VBoxNsprPR_SetThreadGCAble
67#define PR_ClearThreadGCAble VBoxNsprPR_ClearThreadGCAble
68#define PR_SuspendAll VBoxNsprPR_SuspendAll
69#define PR_ResumeAll VBoxNsprPR_ResumeAll
70#define PR_GetSP VBoxNsprPR_GetSP
71#define GetExecutionEnvironment VBoxNsprGetExecutionEnvironment
72#define SetExecutionEnvironment VBoxNsprSetExecutionEnvironment
73#define PR_EnumerateThreads VBoxNsprPR_EnumerateThreads
74#define PR_ThreadScanStackPointers VBoxNsprPR_ThreadScanStackPointers
75#define PR_ScanStackPointers VBoxNsprPR_ScanStackPointers
76#define PR_GetStackSpaceLeft VBoxNsprPR_GetStackSpaceLeft
77#define PR_NewNamedMonitor VBoxNsprPR_NewNamedMonitor
78#define PR_TestAndLock VBoxNsprPR_TestAndLock
79#define PR_TestAndEnterMonitor VBoxNsprPR_TestAndEnterMonitor
80#define PR_GetMonitorEntryCount VBoxNsprPR_GetMonitorEntryCount
81#define PR_CTestAndEnterMonitor VBoxNsprPR_CTestAndEnterMonitor
82#define PR_Mac_WaitForAsyncNotify VBoxNsprPR_Mac_WaitForAsyncNotify
83#define PR_Mac_PostAsyncNotify VBoxNsprPR_Mac_PostAsyncNotify
84#define PR_OS2_SetFloatExcpHandler VBoxNsprPR_OS2_SetFloatExcpHandler
85#define PR_OS2_UnsetFloatExcpHandler VBoxNsprPR_OS2_UnsetFloatExcpHandler
86#define PR_XLock VBoxNsprPR_XLock
87#define PR_XUnlock VBoxNsprPR_XUnlock
88#define PR_XIsLocked VBoxNsprPR_XIsLocked
89#define PR_XWait VBoxNsprPR_XWait
90#define PR_XNotify VBoxNsprPR_XNotify
91#define PR_XNotifyAll VBoxNsprPR_XNotifyAll
92#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
93
94PR_BEGIN_EXTERN_C
95
96/*---------------------------------------------------------------------------
97** THREAD PRIVATE FUNCTIONS
98---------------------------------------------------------------------------*/
99
100/*
101** Associate a thread object with an existing native thread.
102** "type" is the type of thread object to attach
103** "priority" is the priority to assign to the thread
104** "stack" defines the shape of the threads stack
105**
106** This can return NULL if some kind of error occurs, or if memory is
107** tight. This call invokes "start(obj,arg)" and returns when the
108** function returns. The thread object is automatically destroyed.
109**
110** This call is not normally needed unless you create your own native
111** thread. PR_Init does this automatically for the primordial thread.
112*/
113NSPR_API(PRThread*) PR_AttachThread(PRThreadType type,
114 PRThreadPriority priority,
115 PRThreadStack *stack);
116
117/*
118** Detach the nspr thread from the currently executing native thread.
119** The thread object will be destroyed and all related data attached
120** to it. The exit procs will be invoked.
121**
122** This call is not normally needed unless you create your own native
123** thread. PR_Exit will automatially detach the nspr thread object
124** created by PR_Init for the primordial thread.
125**
126** This call returns after the nspr thread object is destroyed.
127*/
128NSPR_API(void) PR_DetachThread(void);
129
130/*
131** Get the id of the named thread. Each thread is assigned a unique id
132** when it is created or attached.
133*/
134NSPR_API(PRUint32) PR_GetThreadID(PRThread *thread);
135
136/*
137** Set the procedure that is called when a thread is dumped. The procedure
138** will be applied to the argument, arg, when called. Setting the procedure
139** to NULL effectively removes it.
140*/
141typedef void (*PRThreadDumpProc)(PRFileDesc *fd, PRThread *t, void *arg);
142NSPR_API(void) PR_SetThreadDumpProc(
143 PRThread* thread, PRThreadDumpProc dump, void *arg);
144
145/*
146** Get this thread's affinity mask. The affinity mask is a 32 bit quantity
147** marking a bit for each processor this process is allowed to run on.
148** The processor mask is returned in the mask argument.
149** The least-significant-bit represents processor 0.
150**
151** Returns 0 on success, -1 on failure.
152*/
153NSPR_API(PRInt32) PR_GetThreadAffinityMask(PRThread *thread, PRUint32 *mask);
154
155/*
156** Set this thread's affinity mask.
157**
158** Returns 0 on success, -1 on failure.
159*/
160NSPR_API(PRInt32) PR_SetThreadAffinityMask(PRThread *thread, PRUint32 mask );
161
162/*
163** Set the default CPU Affinity mask.
164**
165*/
166NSPR_API(PRInt32) PR_SetCPUAffinityMask(PRUint32 mask);
167
168/*
169** Show status of all threads to standard error output.
170*/
171NSPR_API(void) PR_ShowStatus(void);
172
173/*
174** Set thread recycle mode to on (1) or off (0)
175*/
176NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag);
177
178
179/*---------------------------------------------------------------------------
180** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS
181---------------------------------------------------------------------------*/
182
183/*
184** Only Garbage collectible threads participate in resume all, suspend all and
185** enumeration operations. They are also different during creation when
186** platform specific action may be needed (For example, all Solaris GC able
187** threads are bound threads).
188*/
189
190/*
191** Same as PR_CreateThread except that the thread is marked as garbage
192** collectible.
193*/
194NSPR_API(PRThread*) PR_CreateThreadGCAble(PRThreadType type,
195 void (*start)(void *arg),
196 void *arg,
197 PRThreadPriority priority,
198 PRThreadScope scope,
199 PRThreadState state,
200 PRUint32 stackSize);
201
202/*
203** Same as PR_AttachThread except that the thread being attached is marked as
204** garbage collectible.
205*/
206NSPR_API(PRThread*) PR_AttachThreadGCAble(PRThreadType type,
207 PRThreadPriority priority,
208 PRThreadStack *stack);
209
210/*
211** Mark the thread as garbage collectible.
212*/
213NSPR_API(void) PR_SetThreadGCAble(void);
214
215/*
216** Unmark the thread as garbage collectible.
217*/
218NSPR_API(void) PR_ClearThreadGCAble(void);
219
220/*
221** This routine prevents all other GC able threads from running. This call is needed by
222** the garbage collector.
223*/
224NSPR_API(void) PR_SuspendAll(void);
225
226/*
227** This routine unblocks all other GC able threads that were suspended from running by
228** PR_SuspendAll(). This call is needed by the garbage collector.
229*/
230NSPR_API(void) PR_ResumeAll(void);
231
232/*
233** Return the thread stack pointer of the given thread.
234** Needed by the garbage collector.
235*/
236NSPR_API(void *) PR_GetSP(PRThread *thread);
237
238/*
239** (Get|Set)ExecutionEnvironent
240**
241** Used by Java to associate it's execution environment so garbage collector
242** can find it. If return is NULL, then it's probably not a collectable thread.
243**
244** There's no locking required around these calls.
245*/
246NSPR_API(void*) GetExecutionEnvironment(PRThread *thread);
247NSPR_API(void) SetExecutionEnvironment(PRThread* thread, void *environment);
248
249/*
250** Enumeration function that applies "func(thread,i,arg)" to each active
251** thread in the process. The enumerator returns PR_SUCCESS if the enumeration
252** should continue, any other value is considered failure, and enumeration
253** stops, returning the failure value from PR_EnumerateThreads.
254** Needed by the garbage collector.
255*/
256typedef PRStatus (PR_CALLBACK *PREnumerator)(PRThread *t, int i, void *arg);
257NSPR_API(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg);
258
259/*---------------------------------------------------------------------------
260** THREAD CPU PRIVATE FUNCTIONS
261---------------------------------------------------------------------------*/
262
263/*
264** Get a pointer to the primordial CPU.
265*/
266NSPR_API(struct _PRCPU *) _PR_GetPrimordialCPU(void);
267
268/*---------------------------------------------------------------------------
269** THREAD SYNCHRONIZATION PRIVATE FUNCTIONS
270---------------------------------------------------------------------------*/
271
272/*
273** Create a new named monitor (named for debugging purposes).
274** Monitors are re-entrant locks with a built-in condition variable.
275**
276** This may fail if memory is tight or if some operating system resource
277** is low.
278*/
279NSPR_API(PRMonitor*) PR_NewNamedMonitor(const char* name);
280
281/*
282** Test and then lock the lock if it's not already locked by some other
283** thread. Return PR_FALSE if some other thread owned the lock at the
284** time of the call.
285*/
286NSPR_API(PRBool) PR_TestAndLock(PRLock *lock);
287
288/*
289** Test and then enter the mutex associated with the monitor if it's not
290** already entered by some other thread. Return PR_FALSE if some other
291** thread owned the mutex at the time of the call.
292*/
293NSPR_API(PRBool) PR_TestAndEnterMonitor(PRMonitor *mon);
294
295/*
296** Return the number of times that the current thread has entered the
297** mutex. Returns zero if the current thread has not entered the mutex.
298*/
299NSPR_API(PRIntn) PR_GetMonitorEntryCount(PRMonitor *mon);
300
301/*
302** Just like PR_CEnterMonitor except that if the monitor is owned by
303** another thread NULL is returned.
304*/
305NSPR_API(PRMonitor*) PR_CTestAndEnterMonitor(void *address);
306
307/*---------------------------------------------------------------------------
308** PLATFORM-SPECIFIC INITIALIZATION FUNCTIONS
309---------------------------------------------------------------------------*/
310/* I think PR_GetMonitorEntryCount is useless. All you really want is this... */
311#define PR_InMonitor(m) (PR_GetMonitorEntryCount(m) > 0)
312
313/*---------------------------------------------------------------------------
314** Special X-Lock hack for client
315---------------------------------------------------------------------------*/
316
317#ifdef XP_UNIX
318extern void PR_XLock(void);
319extern void PR_XUnlock(void);
320extern PRBool PR_XIsLocked(void);
321#endif /* XP_UNIX */
322
323PR_END_EXTERN_C
324
325#endif /* pprthred_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette