tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

prthreadstate.rst (1710B)


      1 PRThreadState
      2 =============
      3 
      4 A thread's thread state is either joinable or unjoinable.
      5 
      6 
      7 Syntax
      8 ------
      9 
     10 .. code::
     11 
     12   #include <prthread.h>
     13 
     14   typedef enum PRThreadState {
     15      PR_JOINABLE_THREAD,
     16      PR_UNJOINABLE_THREAD
     17   } PRThreadState;
     18 
     19 
     20 Enumerators
     21 ~~~~~~~~~~~
     22 
     23 ``PR_UNJOINABLE_THREAD``
     24   Thread termination happens implicitly when the thread returns from
     25   the root function. The time of release of the resources assigned to
     26   the thread cannot be determined in advance. Threads created with a
     27   ``PR_UNJOINABLE_THREAD`` state cannot be used as arguments to
     28   :ref:`PR_JoinThread`.
     29 ``PR_JOINABLE_THREAD``
     30   Joinable thread references remain valid after they have returned from
     31   their root function until :ref:`PR_JoinThread` is called. This approach
     32   facilitates management of the process' critical resources.
     33 
     34 
     35 Description
     36 -----------
     37 
     38 A thread is a critical resource and must be managed.
     39 
     40 The lifetime of a thread extends from the time it is created to the time
     41 it returns from its root function. What happens when it returns from its
     42 root function depends on the thread state passed to :ref:`PR_CreateThread`
     43 when the thread was created.
     44 
     45 If a thread is created as a joinable thread, it continues to exist after
     46 returning from its root function until another thread joins it. The join
     47 process permits strict synchronization of thread termination and
     48 therefore promotes effective resource management.
     49 
     50 If a thread is created as an unjoinable (also called detached) thread,
     51 it terminates and cleans up after itself after returning from its root
     52 function. This results in some ambiguity after the thread's root
     53 function has returned and before the thread has finished terminating
     54 itself.