locks.rst (1488B)
1 This chapter describes the NSPR API for creation and manipulation of a 2 mutex of type :ref:`PRLock`. 3 4 - `Lock Type <#Lock_Type>`__ 5 - `Lock Functions <#Lock_Functions>`__ 6 7 In NSPR, a mutex of type :ref:`PRLock` controls locking, and associated 8 condition variables communicate changes in state among threads. When a 9 programmer associates a mutex with an arbitrary collection of data, the 10 mutex provides a protective monitor around the data. 11 12 In general, a monitor is a conceptual entity composed of a mutex, one or 13 more condition variables, and the monitored data. Monitors in this 14 generic sense should not be confused with monitors used in Java 15 programming. In addition to :ref:`PRLock`, NSPR provides another mutex 16 type, :ref:`PRMonitor`, which is reentrant and can have only one associated 17 condition variable. :ref:`PRMonitor` is intended for use with Java and 18 reflects the Java approach to thread synchronization. 19 20 For an introduction to NSPR thread synchronization, including locks and 21 condition variables, see `Introduction to 22 NSPR <Introduction_to_NSPR>`__. 23 24 For reference information on NSPR condition variables, see `Condition 25 Variables <Condition_Variables>`__. 26 27 .. _Lock_Type: 28 29 Lock Type 30 --------- 31 32 - :ref:`PRLock` 33 34 .. _Lock_Functions: 35 36 Lock Functions 37 -------------- 38 39 - :ref:`PR_NewLock` creates a new lock object. 40 - :ref:`PR_DestroyLock` destroys a specified lock object. 41 - :ref:`PR_Lock` locks a specified lock object. 42 - :ref:`PR_Unlock` unlocks a specified lock object.