libsync::Completion

#include <completion.h>

C++ wrapper for a completion object, |sync_completion_t|.

Summary

A |Completion| is a synchronization primitive that allows for one or more threads to wait for a signal from another thread.

See for full details.

This class is thread-safe.

Public functions

Reset()
void
Resets the completion object's signaled state to unsignaled.
Signal()
void
Awakens all waiters on the completion, and marks it as signaled.
Wait()
void
Waits until woken by a call to |Signal| or if the completion has already been signaled.
Wait(zx::duration timeout)
zx_status_t
Returns ZX_ERR_TIMED_OUT if |timeout| elapses, and ZX_OK if woken by a call to |Signal| or if the completion has already been signaled.
Wait(zx::time deadline)
zx_status_t
Returns ZX_ERR_TIMED_OUT if |deadline| elapses, and ZX_OK if woken by a call to |Signal| or if the completion has already been signaled.
get()
sync_completion_t *
Gets the underlying |sync_completion_t|.
get() const
const sync_completion_t *
Gets the underlying |sync_completion_t|.
signaled() const
bool
Returns true iff the completion object has been signaled.

Public functions

Reset

void Reset()

Resets the completion object's signaled state to unsignaled.

Signal

void Signal()

Awakens all waiters on the completion, and marks it as signaled.

Waits after this call but before a reset of the completion will also see the signal and immediately return.

Wait

void Wait()

Waits until woken by a call to |Signal| or if the completion has already been signaled.

Wait

zx_status_t Wait(
  zx::duration timeout
)

Returns ZX_ERR_TIMED_OUT if |timeout| elapses, and ZX_OK if woken by a call to |Signal| or if the completion has already been signaled.

Wait

zx_status_t Wait(
  zx::time deadline
)

Returns ZX_ERR_TIMED_OUT if |deadline| elapses, and ZX_OK if woken by a call to |Signal| or if the completion has already been signaled.

get

sync_completion_t * get()

Gets the underlying |sync_completion_t|.

get

const sync_completion_t * get() const 

Gets the underlying |sync_completion_t|.

signaled

bool signaled() const 

Returns true iff the completion object has been signaled.