Fix Centurion name.
[0ad.git] / libraries / source / spidermonkey / include-win32-debug / nspr / prcvar.h
blob161e1429270583e73feb9f1c8e514347819b90db
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef prcvar_h___
7 #define prcvar_h___
9 #include "prlock.h"
10 #include "prinrval.h"
12 PR_BEGIN_EXTERN_C
14 typedef struct PRCondVar PRCondVar;
17 ** Create a new condition variable.
19 ** "lock" is the lock used to protect the condition variable.
21 ** Condition variables are synchronization objects that threads can use
22 ** to wait for some condition to occur.
24 ** This may fail if memory is tight or if some operating system resource
25 ** is low. In such cases, a NULL will be returned.
27 NSPR_API(PRCondVar*) PR_NewCondVar(PRLock *lock);
30 ** Destroy a condition variable. There must be no thread
31 ** waiting on the condvar. The caller is responsible for guaranteeing
32 ** that the condvar is no longer in use.
35 NSPR_API(void) PR_DestroyCondVar(PRCondVar *cvar);
38 ** The thread that waits on a condition is blocked in a "waiting on
39 ** condition" state until another thread notifies the condition or a
40 ** caller specified amount of time expires. The lock associated with
41 ** the condition variable will be released, which must have be held
42 ** prior to the call to wait.
44 ** Logically a notified thread is moved from the "waiting on condition"
45 ** state and made "ready." When scheduled, it will attempt to reacquire
46 ** the lock that it held when wait was called.
48 ** The timeout has two well known values, PR_INTERVAL_NO_TIMEOUT and
49 ** PR_INTERVAL_NO_WAIT. The former value requires that a condition be
50 ** notified (or the thread interrupted) before it will resume from the
51 ** wait. If the timeout has a value of PR_INTERVAL_NO_WAIT, the effect
52 ** is to release the lock, possibly causing a rescheduling within the
53 ** runtime, then immediately attempting to reacquire the lock and resume.
55 ** Any other value for timeout will cause the thread to be rescheduled
56 ** either due to explicit notification or an expired interval. The latter
57 ** must be determined by treating time as one part of the monitored data
58 ** being protected by the lock and tested explicitly for an expired
59 ** interval.
61 ** Returns PR_FAILURE if the caller has not locked the lock associated
62 ** with the condition variable or the thread was interrupted (PR_Interrupt()).
63 ** The particular reason can be extracted with PR_GetError().
65 NSPR_API(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout);
68 ** Notify ONE thread that is currently waiting on 'cvar'. Which thread is
69 ** dependent on the implementation of the runtime. Common sense would dictate
70 ** that all threads waiting on a single condition have identical semantics,
71 ** therefore which one gets notified is not significant.
73 ** The calling thead must hold the lock that protects the condition, as
74 ** well as the invariants that are tightly bound to the condition, when
75 ** notify is called.
77 ** Returns PR_FAILURE if the caller has not locked the lock associated
78 ** with the condition variable.
80 NSPR_API(PRStatus) PR_NotifyCondVar(PRCondVar *cvar);
83 ** Notify all of the threads waiting on the condition variable. The order
84 ** that the threads are notified is indeterminant. The lock that protects
85 ** the condition must be held.
87 ** Returns PR_FAILURE if the caller has not locked the lock associated
88 ** with the condition variable.
90 NSPR_API(PRStatus) PR_NotifyAllCondVar(PRCondVar *cvar);
92 PR_END_EXTERN_C
94 #endif /* prcvar_h___ */