condition_variables.rst (1944B)
1 This chapter describes the API for creating and destroying condition 2 variables, notifying condition variables of changes in monitored data, 3 and making a thread wait on such notification. 4 5 - `Condition Variable Type <#Condition_Variable_Type>`__ 6 - `Condition Variable Functions <#Condition_Variable_Functions>`__ 7 8 Conditions are closely associated with a single monitor, which typically 9 consists of a mutex, one or more condition variables, and the monitored 10 data. The association between a condition and a monitor is established 11 when a condition variable is created, and the association persists for 12 its life. In addition, a static association exists between the condition 13 and some data within the monitor. This data is what will be manipulated 14 by the program under the protection of the monitor. 15 16 A call to :ref:`PR_WaitCondVar` causes a thread to block until a specified 17 condition variable receives notification of a change of state in its 18 associated monitored data. Other threads may notify the condition 19 variable when changes occur. 20 21 For an introduction to NSPR thread synchronization, including locks and 22 condition variables, see `Introduction to 23 NSPR <Introduction_to_NSPR>`__. 24 25 For reference information on NSPR locks, see 26 `Locks <NSPR_API_Reference/Locks>`__. 27 28 NSPR provides a special type, :ref:`PRMonitor`, for use with Java. Unlike a 29 mutex of type :ref:`PRLock`, which can have multiple associated condition 30 variables of type :ref:`PRCondVar`, a mutex of type :ref:`PRMonitor` has a 31 single, implicitly associated condition variable. For information about 32 :ref:`PRMonitor`, see `Monitors <Monitors>`__. 33 34 .. _Condition_Variable_Type: 35 36 Condition Variable Type 37 ----------------------- 38 39 - :ref:`PRCondVar` 40 41 .. _Condition_Variable_Functions: 42 43 Condition Variable Functions 44 ---------------------------- 45 46 - :ref:`PR_NewCondVar` 47 - :ref:`PR_DestroyCondVar` 48 - :ref:`PR_WaitCondVar` 49 - :ref:`PR_NotifyCondVar` 50 - :ref:`PR_NotifyAllCondVar`