Class binary_semaphore

Class Documentation

class concore::v1::binary_semaphore

A semaphore that has two states: SIGNALED and WAITING.

It’s assumed that the user will not call signal() multiple times.

It may be implemented exactly as a semaphore, but on some platforms it can be implemented more efficiently.

See

semaphore

Public Functions

binary_semaphore()

Constructor. Puts the semaphore in the SIGNALED state.

~binary_semaphore()

Destructor.

binary_semaphore(const binary_semaphore&) = delete

Copy constructor is DISABLED.

void operator=(const binary_semaphore&) = delete

Copy assignment is DISABLED.

binary_semaphore(binary_semaphore&&) = delete

Move constructor is DISABLED.

void operator=(binary_semaphore&&) = delete

Move assignment is DISABLED.

void wait()

Wait for the semaphore to be signaled.

This will put the binary semaphore in the WAITING state, and wait for a thread to signal it. The call will block until a corresponding thread will signal it.

See

signal(0)

void signal()

Signal the binary semaphore.

Puts the semaphore in the SIGNALED state. If there is a thread that waits on the semaphore it will wake it.