Simple signaling system. More...
|Initializes the signaling system. More...|
|Resets the signaling system. More...|
|char *||signal_name ()|
|Obtain the name of the signaling system. More...|
|bool||signal_create (signal_t *signal)|
|Create a new signal. More...|
|bool||signal_create_flag (flag_t *flag)|
|Create a new flag. More...|
|bool||signal_connect (signal_t signal, flag_t flag)|
|Connect a signal to a flag. More...|
|void||signal_reset_connections (signal_t signal)|
|Reset connections between a signal and its flags. More...|
|void||signal_emit (signal_t signal)|
|Emit a signal (immediately) More...|
|void||signal_emit_delayed (signal_t signal, uint_base_t delay)|
|Emit a signal after a delay. More...|
|bool||signal_flag_isset (flag_t flag)|
|Check if a flag is set. More...|
|void||signal_flag_clear (flag_t flag)|
|Clear a flag. More...|
|void||signal_flag_reset (flag_t flag)|
|Reset a flag. More...|
Simple signaling system.
It is designed to be used in a cooperative multi-tasking system where task A needs to send messages (signals) to task B. In order to prevent task B from having a signal-handler function that takes too long to finish executing, hence screwing up the scheduling, the signal is passed to task B by setting a flag which can then be read by task B when it is running. Furthermore task A's signal can be tied to more than one other task's flag.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Definition in file glm_signal.h.
Connect a signal to a flag.
The signal and flag to be interconnected may belong to two different software components. However, they may belong to one and the same software component as well.
|signal||The signal to connect to the flag.|
|flag||The flag to which a_signal must be connected.|
|bool signal_create||(||signal_t *||signal)|
Create a new signal.
After a successful creation the signal can be emitted by its owner at any point in time by calling signal_emit(). All flags connected to this signal will be set upon emission.
|signal||Pointer to variable in which to store the new signal's ID.|
|bool signal_create_flag||(||flag_t *||flag)|
Create a new flag.
After successful creation the flag can be connected to one or more signals using signal_connect(). The flag will then be set every time one of the connected signals emit.
During use a single flag may be set multiple times (by the same or different signals. The number of times a flag can be set is limited by the upper limit of the tick type (uint_base_t). The upper limit of the type uint_base_t is always 2^N-1, where N is equal to the bit-with of the integer-registers on your system - as selected with the CORE_*BIT-parameter in glm_conf.h.
|flag||Pointer to variable in which to store the new flag's ID.|
Emit a signal after a delay.
All flags connected to the signal are set after the given delay. The delay is given in ticks, where one tick equals 1/CORE_TICK_FREQ_HZ seconds.
|signal||Signal to emit.|
|delay||Delay in ticks after which to the emit signal.|
Initializes the signaling system.
This function has to be called before using the signaling system and after calling signal_reset(). The initialization consists merely of obtaining the heap-ID, which is needed for its successful operation.