Product SiteDocumentation Site


tc_signal_init, tc_signal_subscribe, tc_signal_unsubscribe, tc_signal_fire, tc_signal_destroy — libtcr signaling functions


#include <tc/threaded_cr.h>

void tc_signal_init(struct tc_signal *s);

struct tc_signal_sub *tc_signal_subscribe(struct tc_signal *s);

void tc_signal_unsubscribe(struct tc_signal *s, struct tc_signal_sub *ss);

void tc_signal_fire(struct tc_signal *s);

void tc_signal_destroy(struct tc_signal *s);


Tc_signals are used for asynchronous notification between tc_threads. As of today they do not have any relation to system level (unix) signals.
Signals are guaranteed to get delivered once. When the subscriber of the signal does not sleep in a sleeping libtcr call, then the signal will get delivered when a sleeping function is called the next time. A signal that is fired multiple times before it gets delivered, gets delivered only once.
Before a tc_signals may be used, it has to be initialized with a call to tc_signal_init(). It may not be used after a call to its destructor tc_signal_destroy().
A call to tc_signal_subscribe() enables interruption of sleeping libtcr calls by that signal for the current tc_thread. Sleeping libtcr functions are: tc_wait_fd(3), tc_mutex_lock(3), tc_thread_wait(3), tc_thread_pool_wait(3), tc_sleep(3) and tc_waitq_wait_event(3).
tc_signal_unsubscribe() disables interruption of sleeping libtcr calls by the passed signal, and subscription object. Note: You have to unsubscribe all tc_signals before calling tc_die(3) or returning from the top most function of a tc_thread.
tc_signal_fire() activates a signal once, for all subscribers of that signal.


Philipp Reisner