struct zxr_thread

Defined at line 23 of file ../../sdk/lib/c/threads/zxr-thread.h

Public Members

zx_handle_t handle
_Atomic(int) state

Public Methods

zx_futex_t * StateFutex ()

Defined at line 42 of file ../../sdk/lib/c/threads/zxr-thread.h

std::optional<State> JoinOrDetachState (State new_state)

Claim the thread as JOINED or DETACHED. Returns std::nullopt on success,

which only happens if the previous state was JOINABLE. On failure, it

returns the actual previous state.

Defined at line 47 of file ../../sdk/lib/c/threads/zxr-thread.h

zx::thread TakeHandle (State expected_state)

Extract the thread handle. Synchronizes with readers by setting the state

to FREED and checks the given expected state for consistency.

Defined at line 58 of file ../../sdk/lib/c/threads/zxr-thread.h

Enumerations

enum State
Name Value
JOINABLE 0
DETACHED 1
JOINED 2
EXITING 3
DONE 4
FREED 5

A zxr_thread_t starts its life JOINABLE.

- If someone calls zxr_thread_join on it, it transitions to JOINED.

- If someone calls ThreadDetach on it, it transitions to DETACHED.

- When it begins exiting, the EXITING state is entered.

- When it is no longer using its memory and handle resources, it transitions

to DONE. If the thread was DETACHED prior to EXITING, this transition MAY

not happen.

No other transitions occur.

Defined at line 33 of file ../../sdk/lib/c/threads/zxr-thread.h