summaryrefslogtreecommitdiffstats
path: root/docs/nspr/reference/condition_variables.rst
blob: b5a1b5abcb09d13c5ce7a81c4e5617f55316fe95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
This chapter describes the API for creating and destroying condition
variables, notifying condition variables of changes in monitored data,
and making a thread wait on such notification.

-  `Condition Variable Type <#Condition_Variable_Type>`__
-  `Condition Variable Functions <#Condition_Variable_Functions>`__

Conditions are closely associated with a single monitor, which typically
consists of a mutex, one or more condition variables, and the monitored
data. The association between a condition and a monitor is established
when a condition variable is created, and the association persists for
its life. In addition, a static association exists between the condition
and some data within the monitor. This data is what will be manipulated
by the program under the protection of the monitor.

A call to :ref:`PR_WaitCondVar` causes a thread to block until a specified
condition variable receives notification of a change of state in its
associated monitored data. Other threads may notify the condition
variable when changes occur.

For an introduction to NSPR thread synchronization, including locks and
condition variables, see `Introduction to
NSPR <Introduction_to_NSPR>`__.

For reference information on NSPR locks, see
`Locks <NSPR_API_Reference/Locks>`__.

NSPR provides a special type, :ref:`PRMonitor`, for use with Java. Unlike a
mutex of type :ref:`PRLock`, which can have multiple associated condition
variables of type :ref:`PRCondVar`, a mutex of type :ref:`PRMonitor` has a
single, implicitly associated condition variable. For information about
:ref:`PRMonitor`, see `Monitors <Monitors>`__.

.. _Condition_Variable_Type:

Condition Variable Type
-----------------------

 - :ref:`PRCondVar`

.. _Condition_Variable_Functions:

Condition Variable Functions
----------------------------

 - :ref:`PR_NewCondVar`
 - :ref:`PR_DestroyCondVar`
 - :ref:`PR_WaitCondVar`
 - :ref:`PR_NotifyCondVar`
 - :ref:`PR_NotifyAllCondVar`