12 #define DISPATCH_NEW_PRIVATE
13 #define DISPATCH_PRIVATE
33 uint16_t *maxptr = NULL;
37 else if (u && *u > *maxptr)
39 } SMARTLIST_FOREACH_END(u);
41 return maxptr ? *maxptr : dflt;
49 CTASSERT(
sizeof(uint16_t) ==
sizeof(channel_id_t));
57 return tor_strdup(
"<>");
94 size_t n_recv = smartlist_len(receivers);
96 ent = tor_malloc_zero(offsetof(dtbl_entry_t, rcv) +
97 sizeof(dispatch_rcv_t) * n_recv);
102 memcpy(&ent->rcv[rcv_sl_idx], rcv,
sizeof(*rcv));
106 } SMARTLIST_FOREACH_END(rcv);
122 const size_t n_chans = (size_t)
131 d->n_queues = n_chans;
132 d->n_types = n_types;
136 for (
size_t i = 0; i < n_types; ++i) {
144 d->typefns[fns_sl_idx].free_fn = fns->free_fn;
146 d->typefns[fns_sl_idx].fmt_fn = fns->fmt_fn;
148 } SMARTLIST_FOREACH_END(fns);
151 d->queues = tor_calloc(d->n_queues,
sizeof(dqueue_t));
152 for (
size_t i = 0; i < d->n_queues; ++i) {
153 TOR_SIMPLEQ_INIT(&d->queues[i].queue);
158 d->table = tor_calloc(d->n_msgs,
sizeof(dtbl_entry_t *));
161 } SMARTLIST_FOREACH_END(rcv);
166 if (d->table[type_sl_idx])
167 d->table[type_sl_idx]->type = *type;
168 } SMARTLIST_FOREACH_END(type);
171 if (d->table[chan_sl_idx])
172 d->table[chan_sl_idx]->channel = *chan;
173 } SMARTLIST_FOREACH_END(chan);
Macro definitions for MIN, MAX, and CLAMP.
Compile-time assertions: CTASSERT(expression).
Low-level APIs for message-passing system.
struct dispatch_t dispatch_t
Header for distpach_cfg.c.
Declarations for dispatch-configuration types.
static void alert_fn_nop(dispatch_t *d, channel_id_t ch, void *arg)
dispatch_t * dispatch_new(const dispatch_cfg_t *cfg)
static dispatch_typefns_t nop_typefns
static char * type_fmt_nop(msg_aux_data_t arg)
static void type_free_nop(msg_aux_data_t arg)
STATIC int max_in_u16_sl(const smartlist_t *sl, int dflt)
static dtbl_entry_t * dtbl_entry_from_lst(smartlist_t *receivers)
private structures used for the dispatcher module
Headers for util_malloc.c.
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
struct smartlist_t * type_by_msg
struct smartlist_t * recv_by_msg
struct smartlist_t * chan_by_msg
struct smartlist_t * fns_by_type
void(* free_fn)(msg_aux_data_t)
Macros to manage assertions, fatal and non-fatal.