ao_bsem.h
Binary semaphores

Notes

This module defines binary semaphore.

Include

ao_async.h
ao_list.h
ao_time.h
stdbool.h

Types

ao_bsem_t

typedef struct ao_bsem_t ao_bsem_t;

Represents a binary semaphore.

ao_bsem_take_t

typedef struct ao_bsem_take_t ao_bsem_take_t;

Represents the taking of a binary semaphore.

Structs

ao_bsem_t

struct ao_bsem_t
{
    ao_list_t take;
    bool      taken;
};
take The list of takings.
taken Indicates whether the semaphore is taken.

ao_bsem_take_t

struct ao_bsem_take_t
{
    ao_async_t     async;
    ao_bsem_t *    bsem;
    ao_list_node_t bsem_take_node;
    bool volatile  result;
};
async The asynchronous event.
bsem The binary semaphore.
bsem_take_node The node for the binary semaphore’s list of takings.
result The result.

Functions

ao_bsem_give

void ao_bsem_give(ao_bsem_t * b);

Gives a binary semaphore.

ao_bsem_take

ao_bsem_take_from

bool ao_bsem_take     (ao_bsem_t * b, ao_time_t timeout);
bool ao_bsem_take_from(ao_bsem_t * b, ao_time_t timeout, ao_time_t beginning);

Takes a binary semaphore in a blocking fashion with a timeout and an optional beginning.

ao_bsem_take_forever

bool ao_bsem_take_forever(ao_bsem_t * b);

Takes a binary semaphore indefinitely in a blocking fashion.

ao_bsem_take_try

bool ao_bsem_take_try(ao_bsem_t * b);

Takes a binary semaphore in a non-blocking fashion.

ao_bsem_take_begin

ao_bsem_take_end

void ao_bsem_take_begin(ao_bsem_take_t * t);
void ao_bsem_take_end  (ao_bsem_take_t * t);

Begins or ends, respectively, a taking of a binary semaphore.

External Links