Bug 1885489 - Part 9: Add SnapshotIterator::readObject(). r=iain
[gecko.git] / docs / nspr / reference / pr_sleep.rst
blobb3ad0ec2cd7d77aec43108c951a8014ae158d2e5
1 PR_Sleep
2 ========
4 Causes the current thread to yield for a specified amount of time.
7 Syntax
8 ------
10 .. code::
12    #include <prthread.h>
14    PRStatus PR_Sleep(PRIntervalTime ticks);
17 Parameter
18 ~~~~~~~~~
20 :ref:`PR_Sleep` has the following parameter:
22 ``ticks``
23    The number of ticks you want the thread to sleep for (see
24    :ref:`PRIntervalTime`).
27 Returns
28 ~~~~~~~
30 Calling :ref:`PR_Sleep` with a parameter equivalent to
31 ``PR_INTERVAL_NO_TIMEOUT`` is an error and results in a ``PR_FAILURE``
32 error.
35 Description
36 -----------
38 :ref:`PR_Sleep` simply waits on a condition for the amount of time
39 specified. If you set ticks to ``PR_INTERVAL_NO_WAIT``, the thread
40 yields.
42 If ticks is not ``PR_INTERVAL_NO_WAIT``, :ref:`PR_Sleep` uses an existing
43 lock, but has to create a new condition for this purpose. If you have
44 already created such structures, it is more efficient to use them
45 directly.
47 Calling :ref:`PR_Sleep` with the value of ticks set to
48 ``PR_INTERVAL_NO_WAIT`` simply surrenders the processor to ready threads
49 of the same priority. All other values of ticks cause :ref:`PR_Sleep` to
50 block the calling thread for the specified interval.
52 Threads blocked in :ref:`PR_Sleep` are interruptible.