summaryrefslogtreecommitdiffstats
path: root/docs/nspr/reference/pr_waitsemaphore.rst
blob: 1a0c7b3d1cc8bb59debb784e800c7ac8e0fca2bc (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
PR_WaitSemaphore
================

Returns the value of the environment variable.


Syntax
------

.. code::

   #include <pripcsem.h>

   NSPR_API(PRStatus) PR_WaitSemaphore(PRSem *sem);


Parameter
~~~~~~~~~

The function has the following parameter:

``sem``
   A pointer to a ``PRSem`` structure returned from a call to
   :ref:`PR_OpenSemaphore`.


Returns
~~~~~~~

:ref:`PRStatus`


Description
-----------

:ref:`PR_WaitSemaphore` tests the value of the semaphore. If the value of
the semaphore is > 0, the value of the semaphore is decremented and the
function returns. If the value of the semaphore is 0, the function
blocks until the value becomes > 0, then the semaphore is decremented
and the function returns.

The "test and decrement" operation is performed atomically.