11 #define CHANNEL_OBJECT_PRIVATE
13 #define SCHEDULER_PRIVATE
21 #define MAX_FLUSH_CELLS 1000
35 return smartlist_len(cp) > 0;
52 vanilla_scheduler_run(
void)
54 int n_cells, n_chans_before, n_chans_after;
55 ssize_t flushed, flushed_this_time;
60 log_debug(
LD_SCHED,
"We have a chance to run the scheduler");
62 n_chans_before = smartlist_len(cp);
64 while (smartlist_len(cp) > 0) {
80 "Scheduler saw pending channel %"PRIu64
" at %p with "
85 while (flushed < n_cells) {
88 MIN(MAX_FLUSH_CELLS, (
size_t) n_cells - flushed));
89 if (flushed_this_time <= 0)
break;
90 flushed += flushed_this_time;
93 if (flushed < n_cells) {
105 "Channel %"PRIu64
" at %p "
132 "Scheduler flushed %d cells onto pending channel "
138 "Scheduler saw pending channel %"PRIu64
" at %p with "
139 "no cells writeable",
154 } SMARTLIST_FOREACH_END(readd_chan);
155 smartlist_free(to_readd);
158 n_chans_after = smartlist_len(cp);
159 log_debug(
LD_SCHED,
"Scheduler handled %d of %d pending channels",
160 n_chans_before - n_chans_after, n_chans_before);
165 .type = SCHEDULER_VANILLA,
167 .on_channel_free = NULL,
169 .on_new_consensus = NULL,
171 .run = vanilla_scheduler_run,
172 .on_new_options = NULL,
176 get_vanilla_scheduler(
void)
178 return &vanilla_scheduler;
ssize_t channel_flush_some_cells(channel_t *chan, ssize_t num_cells)
int channel_num_cells_writeable(channel_t *chan)
int channel_more_to_flush(channel_t *chan)
Header file for channel.c.
Header file for config.c.
Master header file for Tor-specific functionality.
void scheduler_ev_active(void)
int scheduler_compare_channels(const void *c1_v, const void *c2_v)
void scheduler_set_channel_state(channel_t *chan, int new_state)
smartlist_t * get_channels_pending(void)
Header file for scheduler*.c.
static void vanilla_scheduler_schedule(void)
void smartlist_pqueue_add(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset, void *item)
void * smartlist_pqueue_pop(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
uint64_t global_identifier
#define IF_BUG_ONCE(cond)