VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/prmon.h

Last change on this file was 106112, checked in by vboxsync, 4 months ago

libs/xpcom: Fix building code using the XPCOM SDK bindings outside of VirtualBox, ticketref:22714 bugref:10773

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 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 prmon_h___
39#define prmon_h___
40
41#include "prtypes.h"
42
43#ifdef VBOX
44# include <iprt/types.h>
45#endif
46
47#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
48#define PR_EnterMonitor VBoxNsprPR_EnterMonitor
49#define PR_ExitMonitor VBoxNsprPR_ExitMonitor
50#define PR_Notify VBoxNsprPR_Notify
51#define PR_NotifyAll VBoxNsprPR_NotifyAll
52#define PR_Wait VBoxNsprPR_Wait
53#define PR_NewMonitor VBoxNsprPR_NewMonitor
54#define PR_DestroyMonitor VBoxNsprPR_DestroyMonitor
55#define PR_GetMonitorEntryCount VBoxNsprPR_GetMonitorEntryCount
56#define PR_NewNamedMonitor VBoxNsprPR_NewNamedMonitor
57#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
58
59PR_BEGIN_EXTERN_C
60
61typedef struct PRMonitor PRMonitor;
62
63#ifdef VBOX
64/*
65** Create a new monitor. Monitors are re-entrant locks with a single built-in
66** condition variable.
67**
68** This may fail if memory is tight or if some operating system resource
69** is low.
70*/
71NSPR_API(PRMonitor*) PR_NewMonitor(void);
72
73/*
74** Destroy a monitor. The caller is responsible for guaranteeing that the
75** monitor is no longer in use. There must be no thread waiting on the monitor's
76** condition variable and that the lock is not held.
77**
78*/
79NSPR_API(void) PR_DestroyMonitor(PRMonitor *mon);
80
81/*
82** Enter the lock associated with the monitor. If the calling thread currently
83** is in the monitor, the call to enter will silently succeed. In either case,
84** it will increment the entry count by one.
85*/
86NSPR_API(void) PR_EnterMonitor(PRMonitor *mon);
87
88/*
89** Decrement the entry count associated with the monitor. If the decremented
90** entry count is zero, the monitor is exited. Returns PR_FAILURE if the
91** calling thread has not entered the monitor.
92*/
93NSPR_API(PRStatus) PR_ExitMonitor(PRMonitor *mon);
94
95/*
96** Wait for a notify on the monitor's condition variable. Sleep for "ticks"
97** amount of time (if "ticks" is PR_INTERVAL_NO_TIMEOUT then the sleep is
98** indefinite).
99**
100** While the thread is waiting it exits the monitor (as if it called
101** PR_ExitMonitor as many times as it had called PR_EnterMonitor). When
102** the wait has finished the thread regains control of the monitors lock
103** with the same entry count as before the wait began.
104**
105** The thread waiting on the monitor will be resumed when the monitor is
106** notified (assuming the thread is the next in line to receive the
107** notify) or when the "ticks" timeout elapses.
108**
109** Returns PR_FAILURE if the caller has not entered the monitor.
110*/
111NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, RTMSINTERVAL msWait);
112
113/*
114** Notify a thread waiting on the monitor's condition variable. If a thread
115** is waiting on the condition variable (using PR_Wait) then it is awakened
116** and attempts to reenter the monitor.
117*/
118NSPR_API(PRStatus) PR_Notify(PRMonitor *mon);
119
120/*
121** Notify all of the threads waiting on the monitor's condition variable.
122** All of threads waiting on the condition are scheduled to reenter the
123** monitor.
124*/
125NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon);
126
127/*
128** Return the number of times that the current thread has entered the
129** mutex. Returns zero if the current thread has not entered the mutex.
130*/
131NSPR_API(uint32_t) PR_GetMonitorEntryCount(PRMonitor *mon);
132
133NSPR_API(PRMonitor*) PR_NewNamedMonitor(const char* name);
134#endif
135
136PR_END_EXTERN_C
137
138#endif /* prmon_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