Overview
-
asynchronous events (checking, callbacks)
- awaiting a single asynchronous event
-
difference to async-await pattern
-
polling for a single asynchronous event
- awaiting or polling for one out many asynchronous events
-
awaiting or polling for all out many asynchronous events
- proxies
- task does not directly wait for a resources, but uses a proxy object that represents the waiting.
- the proxy can be allocated on the stack
- the proxy encapsulates an asynchronous event and all other information about the waiting (e.g. result)
- the proxy concept allows to clearly separate three stages of waiting: (1) begin or prepare (2) block (3) end or follow up.
- that separation, in turn, allows to begin a multitude of waitings, then block only once in order to await (any subset) of the respective asynchronous events, then end the multitude of waitings.
-
this leads to greater flexibility in task design and less context switches / overhead
-
the typical synchronization API
- wait_begin(proxy) … begin, not blocking
- wait_end(proxy) … end, not blocking
-
in between, there is supposed to be a call to ao_await(), that might block.
- wait(resource, timeout) … begin, block until timeout expires, end
-
wait_from(resource, timeout, beginning) … begin, block until timeout expires, end
-
wait_forever(resource) … begin, block indefinitely, end
- wait_try(resource) … begin, end
Primitives
The following modules provide synchronization primitives.
ao_are.h |
Auto-reset events. |
ao_barrier.h |
Execution barriers where tasks can meet. |
ao_bsem.h |
Binary semaphores. |
ao_cond.h |
Condition variables. |
ao_mail.h |
Mail for asynchronous messaging. |
ao_monitor.h |
Monitors. |
ao_mre.h |
Manual-reset events. |
ao_mutex.h |
Mutexes. |
ao_num.h |
Numbers based on the fastest unsigned integer type. |
ao_num8.h |
Numbers based on the 8-bit unsigned integer type. |
ao_num16.h |
Numbers based on the 16-bit unsigned integer type. |
ao_num32.h |
Numbers based on the 32-bit unsigned integer type. |
ao_num64.h |
Numbers based on the 64-bit unsigned integer type. |
ao_pmail.h |
Priority mail for asynchronous messaging. |
ao_queue4acq.h |
Priority queues for acquired memory blocks. |
ao_queue4obj.h |
Priority queues for objects. |
ao_queue4ptr.h |
Priority queues for pointers. |
ao_recv.h |
Receiving bytes. |
ao_recv_acq.h |
Receiving acquired memory blocks. |
ao_recv_obj.h |
Receiving objects. |
ao_recv_ptr.h |
Receiving pointers. |
ao_rendezvous.h |
Rendezvous. |
ao_rw.h |
Readers-writer locks preferring readers. |
ao_sem.h |
Counting semaphores. |
ao_send.h |
Sending bytes. |
ao_send_acq.h |
Sending acquired memory blocks. |
ao_send_obj.h |
Sending objects. |
ao_send_ptr.h |
Sending pointers. |
ao_signal.h |
Signals. |
ao_sleep.h |
Sleeping. |
ao_stream.h |
Streams for bytes. |
ao_stream4acq.h |
Streams for acquired memory blocks. |
ao_stream4obj.h |
Streams for objects. |
ao_stream4ptr.h |
Streams for pointers. |
ao_threshold.h |
Thresholds based on the fastest unsigned integer type. |
ao_threshold8.h |
Thresholds based on the 8-bit unsigned integer type. |
ao_threshold16.h |
Thresholds based on the 16-bit unsigned integer type. |
ao_threshold32.h |
Thresholds based on the 32-bit unsigned integer type. |
ao_threshold64.h |
Thresholds based on the 64-bit unsigned integer type. |
ao_wr.h |
Readers-writer locks preferring writers. |
ao_xch.h |
Exchanges for client-server messaging. |