12 #define DISPATCH_PRIVATE
60 size_t n_queues = d->n_queues;
61 for (
size_t i = 0; i < n_queues; ++i) {
63 TOR_SIMPLEQ_FOREACH_SAFE(m, &d->queues[i].queue, next, mtmp) {
64 dispatch_free_msg(d, m);
68 size_t n_msgs = d->n_msgs;
70 for (
size_t i = 0; i < n_msgs; ++i) {
91 if (BUG(chan >= d->n_queues))
94 dqueue_t *q = &d->queues[chan];
96 q->alert_fn_arg = userdata;
113 channel_id_t channel,
118 if (!d->table[msg]) {
121 d->typefns[type].free_fn(auxdata);
128 m->channel = channel;
133 return dispatch_send_msg(d, m);
143 if (BUG(m->channel >= d->n_queues))
145 if (BUG(m->msg >= d->n_msgs))
148 dtbl_entry_t *ent = d->table[m->msg];
150 if (BUG(m->
type != ent->type))
152 if (BUG(m->channel != ent->channel))
178 dqueue_t *q = &d->queues[m->channel];
179 bool was_empty = TOR_SIMPLEQ_EMPTY(&q->queue);
182 TOR_SIMPLEQ_INSERT_TAIL(&q->queue, m, next);
187 "Queued: %s (%s) from %s, on %s.",
188 get_message_id_name(m->msg),
190 get_subsys_id_name(m->sender),
198 q->alert_fn(d, m->channel, q->alert_fn_arg);
211 dtbl_entry_t *ent = d->table[m->msg];
212 int n_fns = ent->n_fns;
217 "Delivering: %s (%s) from %s, on %s:",
218 get_message_id_name(m->msg),
220 get_subsys_id_name(m->sender),
226 for (i=0; i < n_fns; ++i) {
227 if (ent->rcv[i].enabled) {
228 log_debug(
LD_MESG,
" Delivering to %s.",
229 get_subsys_id_name(ent->rcv[i].sys));
243 if (BUG(ch >= d->n_queues))
247 dqueue_t *q = &d->queues[ch];
249 while (n_flushed < max_msgs) {
250 msg_t *m = TOR_SIMPLEQ_FIRST(&q->queue);
253 TOR_SIMPLEQ_REMOVE_HEAD(&q->queue, next);
255 dispatch_free_msg(d, m);
Low-level APIs for message-passing system.
void(* dispatch_alertfn_t)(struct dispatch_t *, channel_id_t, void *)
struct dispatch_t dispatch_t
int dispatch_send(dispatch_t *d, subsys_id_t sender, channel_id_t channel, message_id_t msg, msg_type_id_t type, msg_aux_data_t auxdata)
void dispatch_free_msg_(const dispatch_t *d, msg_t *msg)
char * dispatch_fmt_msg_data(const dispatch_t *d, const msg_t *msg)
int dispatch_flush(dispatch_t *d, channel_id_t ch, int max_msgs)
int dispatch_set_alert_fn(dispatch_t *d, channel_id_t chan, dispatch_alertfn_t fn, void *userdata)
static void dispatcher_run_msg_cbs(const dispatch_t *d, msg_t *m)
int dispatch_send_msg_unchecked(dispatch_t *d, msg_t *m)
void dispatch_free_(dispatch_t *d)
Header for dispatch_naming.c.
const char * get_channel_id_name(channel_id_t)
private structures used for the dispatcher module
static bool debug_logging_enabled(void)
Headers for util_malloc.c.
msg_aux_data_t aux_data__
Macros to manage assertions, fatal and non-fatal.