main event loop we use for most processes, schedules computations based on time or network events with priorities More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_SCHEDULER_Handle |
Argument to be passed from the driver to GNUNET_SCHEDULER_do_work(). More... | |
struct | GNUNET_SCHEDULER_Task |
Entry in list of pending tasks. More... | |
struct | Scheduled |
A struct representing an event the select driver is waiting for. More... | |
struct | DriverContext |
Driver context used by GNUNET_SCHEDULER_run. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-scheduler", __VA_ARGS__) |
#define | LOG_STRERROR(kind, syscall) |
#define | PROFILE_DELAYS GNUNET_NO |
Should we figure out which tasks are delayed for a while before they are run? (Consider using in combination with EXECINFO). More... | |
#define | DELAY_THRESHOLD GNUNET_TIME_UNIT_SECONDS |
Task that were in the queue for longer than this are reported if PROFILE_DELAYS is active. More... | |
Functions | |
void | GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select, void *new_select_cls) |
Sets the select function to use in the scheduler (scheduler_select). More... | |
static enum GNUNET_SCHEDULER_Priority | check_priority (enum GNUNET_SCHEDULER_Priority p) |
Check that the given priority is legal (and return it). More... | |
static struct GNUNET_TIME_Absolute | get_timeout () |
chooses the nearest timeout from all pending tasks, to be used to tell the driver the next wakeup time (using its set_wakeup callback) More... | |
static void | remove_pass_end_marker () |
static void | set_work_priority (enum GNUNET_SCHEDULER_Priority p) |
static void | queue_ready_task (struct GNUNET_SCHEDULER_Task *task) |
Put a task that is ready for execution into the ready queue. More... | |
void | GNUNET_SCHEDULER_shutdown () |
Request the shutdown of a scheduler. More... | |
static void | dump_backtrace (struct GNUNET_SCHEDULER_Task *t) |
Output stack trace of task t. More... | |
static void | destroy_task (struct GNUNET_SCHEDULER_Task *t) |
Destroy a task (release associated resources) More... | |
static void | sighandler_pipe () |
Signal handler called for SIGPIPE. More... | |
static void | sighandler_shutdown (void) |
Signal handler called for signals that should cause us to shutdown. More... | |
static void | shutdown_if_no_lifeness (void) |
static enum GNUNET_GenericReturnValue | select_loop (struct GNUNET_SCHEDULER_Handle *sh, struct DriverContext *context) |
void | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Initialize and run scheduler. More... | |
const struct GNUNET_SCHEDULER_TaskContext * | GNUNET_SCHEDULER_get_task_context () |
Obtain the task context, giving the reason why the current task was started. More... | |
unsigned int | GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p) |
Get information about the current load of this scheduler. More... | |
static void | init_fd_info (struct GNUNET_SCHEDULER_Task *t, const struct GNUNET_NETWORK_Handle *const *read_nh, unsigned int read_nh_len, const struct GNUNET_NETWORK_Handle *const *write_nh, unsigned int write_nh_len, const struct GNUNET_DISK_FileHandle *const *read_fh, unsigned int read_fh_len, const struct GNUNET_DISK_FileHandle *const *write_fh, unsigned int write_fh_len) |
static void | driver_add_multiple (struct GNUNET_SCHEDULER_Task *t) |
calls the given function func on each FdInfo related to t. More... | |
static void | install_parent_control_handler (void *cls) |
static void | shutdown_pipe_cb (void *cls) |
void * | GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task) |
Cancel the task with the specified identifier. More... | |
static void | init_backtrace (struct GNUNET_SCHEDULER_Task *t) |
Initialize backtrace data for task t. More... | |
void | GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback task, void *task_cls, enum GNUNET_SCHEDULER_Reason reason, enum GNUNET_SCHEDULER_Priority priority) |
Continue the current execution with the given function. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run at the specified time. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified priority. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run at the specified time. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run as soon as possible. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run as soon as possible with the (transitive) ignore-shutdown flag either explicitly set or explicitly enabled. More... | |
static struct GNUNET_SCHEDULER_Task * | add_without_sets (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, const struct GNUNET_NETWORK_Handle *read_nh, const struct GNUNET_NETWORK_Handle *write_nh, const struct GNUNET_DISK_FileHandle *read_fh, const struct GNUNET_DISK_FileHandle *write_fh, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when any of the specified file descriptor sets is ready. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for reading. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified priority and to be run after the specified delay or when the specified file descriptor is ready for reading. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *wfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for writing. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, struct GNUNET_NETWORK_Handle *fd, int on_read, int on_write, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for reading. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *wfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready for writing. More... | |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, const struct GNUNET_DISK_FileHandle *fd, int on_read, int on_write, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready. More... | |
static void | extract_handles (const struct GNUNET_NETWORK_FDSet *fdset, const struct GNUNET_NETWORK_Handle ***ntarget, unsigned int *extracted_nhandles, const struct GNUNET_DISK_FileHandle ***ftarget, unsigned int *extracted_fhandles) |
struct GNUNET_SCHEDULER_Task * | GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls) |
Schedule a new task to be run with a specified delay or when any of the specified file descriptor sets is ready. More... | |
void | GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, struct GNUNET_SCHEDULER_FdInfo *fdi) |
Function used by event-loop implementations to signal the scheduler that a particular task is ready due to an event specified in the et field of fdi. More... | |
int | GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh) |
Function called by external event loop implementations to tell the scheduler to run some of the tasks that are ready. More... | |
struct GNUNET_SCHEDULER_Handle * | GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver) |
Function called by external event loop implementations to initialize the scheduler. More... | |
void | GNUNET_SCHEDULER_driver_done (struct GNUNET_SCHEDULER_Handle *sh) |
Counter-part of GNUNET_SCHEDULER_driver_init. More... | |
static int | select_add (void *cls, struct GNUNET_SCHEDULER_Task *task, struct GNUNET_SCHEDULER_FdInfo *fdi) |
static int | select_del (void *cls, struct GNUNET_SCHEDULER_Task *task) |
static void | select_set_wakeup (void *cls, struct GNUNET_TIME_Absolute dt) |
struct GNUNET_SCHEDULER_Driver * | GNUNET_SCHEDULER_driver_select () |
Obtain the driver for using select() as the event loop. More... | |
void | GNUNET_SCHEDULER_begin_async_scope (struct GNUNET_AsyncScopeId *aid) |
Change the async scope for the currently executing task and (transitively) for all tasks scheduled by the current task after calling this function. More... | |
Variables | |
static struct GNUNET_SCHEDULER_Task | pass_end_marker |
Placed at the end of a ready queue to indicate where a scheduler run pass ends. More... | |
static const struct GNUNET_SCHEDULER_Driver * | scheduler_driver |
The driver used for the event loop. More... | |
static struct GNUNET_SCHEDULER_Task * | pending_head |
Head of list of tasks waiting for an event. More... | |
static struct GNUNET_SCHEDULER_Task * | pending_tail |
Tail of list of tasks waiting for an event. More... | |
static struct GNUNET_SCHEDULER_Task * | shutdown_head |
Head of list of tasks waiting for shutdown. More... | |
static struct GNUNET_SCHEDULER_Task * | shutdown_tail |
Tail of list of tasks waiting for shutdown. More... | |
static struct GNUNET_SCHEDULER_Task * | pending_timeout_head |
List of tasks waiting ONLY for a timeout event. More... | |
static struct GNUNET_SCHEDULER_Task * | pending_timeout_tail |
List of tasks waiting ONLY for a timeout event. More... | |
static struct GNUNET_SCHEDULER_Task * | pending_timeout_last |
Last inserted task waiting ONLY for a timeout event. More... | |
static struct GNUNET_SCHEDULER_Task * | active_task |
ID of the task that is running right now. More... | |
static struct GNUNET_SCHEDULER_Task * | ready_head [GNUNET_SCHEDULER_PRIORITY_COUNT] |
Head of list of tasks ready to run right now, grouped by importance. More... | |
static struct GNUNET_SCHEDULER_Task * | ready_tail [GNUNET_SCHEDULER_PRIORITY_COUNT] |
Tail of list of tasks ready to run right now, grouped by importance. More... | |
static struct GNUNET_SCHEDULER_Task * | install_parent_control_task |
Task for installing parent control handlers (it might happen that the scheduler is shutdown before this task is executed, so GNUNET_SCHEDULER_shutdown must cancel it in that case) More... | |
static struct GNUNET_SCHEDULER_Task * | shutdown_pipe_task |
Task for reading from a pipe that signal handlers will use to initiate shutdown. More... | |
static unsigned int | ready_count |
Number of tasks on the ready list. More... | |
static enum GNUNET_SCHEDULER_Priority | current_priority |
Priority of the task running right now. More... | |
static enum GNUNET_SCHEDULER_Priority | max_priority_added |
Priority of the highest task added in the current select iteration. More... | |
static int | current_lifeness |
Value of the 'lifeness' flag for the current task. More... | |
static enum GNUNET_SCHEDULER_Priority | work_priority |
Priority used currently in GNUNET_SCHEDULER_do_work(). More... | |
static GNUNET_SCHEDULER_select | scheduler_select |
Function to use as a select() in the scheduler. More... | |
static struct GNUNET_SCHEDULER_TaskContext | tc |
Task context of the current task. More... | |
static void * | scheduler_select_cls |
Closure for scheduler_select. More... | |
static struct GNUNET_DISK_PipeHandle * | shutdown_pipe_handle |
Pipe used to communicate shutdown via signal. More... | |
static pid_t | my_pid |
Process ID of this process at the time we installed the various signal handlers. More... | |
main event loop we use for most processes, schedules computations based on time or network events with priorities
Definition in file scheduler.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-scheduler", __VA_ARGS__) |
Definition at line 32 of file scheduler.c.
#define LOG_STRERROR | ( | kind, | |
syscall | |||
) |
Definition at line 34 of file scheduler.c.
#define PROFILE_DELAYS GNUNET_NO |
Should we figure out which tasks are delayed for a while before they are run? (Consider using in combination with EXECINFO).
Definition at line 68 of file scheduler.c.
#define DELAY_THRESHOLD GNUNET_TIME_UNIT_SECONDS |
Task that were in the queue for longer than this are reported if PROFILE_DELAYS is active.
Definition at line 74 of file scheduler.c.
|
static |
Check that the given priority is legal (and return it).
p | priority value to check |
Definition at line 462 of file scheduler.c.
References GNUNET_assert, GNUNET_SCHEDULER_PRIORITY_COUNT, and p.
Referenced by add_without_sets(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_get_load(), and queue_ready_task().
|
static |
chooses the nearest timeout from all pending tasks, to be used to tell the driver the next wakeup time (using its set_wakeup callback)
Definition at line 477 of file scheduler.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_SCHEDULER_Task::next, pending_head, pending_timeout_head, GNUNET_SCHEDULER_Task::reason, timeout, and GNUNET_SCHEDULER_Task::timeout.
Referenced by GNUNET_SCHEDULER_do_work(), and GNUNET_SCHEDULER_driver_init().
|
static |
Definition at line 515 of file scheduler.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_NO, GNUNET_SCHEDULER_Task::in_ready_list, pass_end_marker, GNUNET_SCHEDULER_Task::priority, ready_head, and ready_tail.
Referenced by GNUNET_SCHEDULER_do_work(), and set_work_priority().
|
static |
Definition at line 528 of file scheduler.c.
References GNUNET_CONTAINER_DLL_insert_tail, GNUNET_YES, GNUNET_SCHEDULER_Task::in_ready_list, p, pass_end_marker, GNUNET_SCHEDULER_Task::priority, ready_head, ready_tail, remove_pass_end_marker(), and work_priority.
Referenced by GNUNET_SCHEDULER_do_work(), and queue_ready_task().
|
static |
Put a task that is ready for execution into the ready queue.
task | task ready for execution |
Definition at line 546 of file scheduler.c.
References check_priority(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_YES, GNUNET_SCHEDULER_Task::in_ready_list, p, GNUNET_SCHEDULER_Task::priority, ready_count, ready_head, ready_tail, set_work_priority(), and work_priority.
Referenced by GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_shutdown(), and GNUNET_SCHEDULER_task_ready().
|
static |
Output stack trace of task t.
t | task to dump stack trace of |
Definition at line 600 of file scheduler.c.
References GNUNET_ERROR_TYPE_WARNING, LOG, and t.
Referenced by GNUNET_SCHEDULER_do_work(), init_backtrace(), and select_loop().
|
static |
Destroy a task (release associated resources)
t | task to destroy |
Definition at line 621 of file scheduler.c.
References GNUNET_DISK_FileHandle::fd, GNUNET_SCHEDULER_FdInfo::fd, GNUNET_NETWORK_Handle::fd, GNUNET_SCHEDULER_Task::fds, GNUNET_SCHEDULER_Task::fds_len, GNUNET_SCHEDULER_FdInfo::fh, GNUNET_array_grow, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_nz, GNUNET_NETWORK_socket_free_memory_only_(), GNUNET_YES, LOG, GNUNET_SCHEDULER_Task::own_handles, and t.
Referenced by GNUNET_SCHEDULER_cancel(), and GNUNET_SCHEDULER_do_work().
|
static |
Signal handler called for SIGPIPE.
Definition at line 672 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_driver_init().
|
static |
Signal handler called for signals that should cause us to shutdown.
Definition at line 682 of file scheduler.c.
References GNUNET_DISK_file_write(), GNUNET_DISK_PIPE_END_WRITE, GNUNET_DISK_pipe_handle(), my_pid, and shutdown_pipe_handle.
Referenced by GNUNET_SCHEDULER_driver_init().
|
static |
Definition at line 699 of file scheduler.c.
References GNUNET_SCHEDULER_shutdown(), GNUNET_YES, GNUNET_SCHEDULER_Task::lifeness, GNUNET_SCHEDULER_Task::next, pending_head, pending_timeout_head, ready_count, shutdown_head, and t.
Referenced by GNUNET_SCHEDULER_do_work().
|
static |
Definition at line 2313 of file scheduler.c.
References context, dump_backtrace(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_NETWORK_fdset_set_native(), GNUNET_NETWORK_fdset_test_native(), GNUNET_NETWORK_fdset_zero(), GNUNET_NETWORK_socket_select(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_ET_IN, GNUNET_SCHEDULER_ET_OUT, GNUNET_SCHEDULER_task_ready(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, LOG, LOG_STRERROR, pending_timeout_head, ready_count, scheduler_select, scheduler_select_cls, and sh.
Referenced by GNUNET_SCHEDULER_run().
|
static |
Definition at line 797 of file scheduler.c.
References GNUNET_SCHEDULER_FdInfo::et, GNUNET_SCHEDULER_FdInfo::fd, GNUNET_SCHEDULER_Task::fds, GNUNET_SCHEDULER_Task::fds_len, GNUNET_SCHEDULER_Task::fdx, GNUNET_SCHEDULER_FdInfo::fh, GNUNET_assert, GNUNET_NETWORK_get_fd(), GNUNET_new_array, GNUNET_SCHEDULER_ET_IN, GNUNET_SCHEDULER_ET_OUT, GNUNET_SCHEDULER_Task::read_fd, GNUNET_SCHEDULER_FdInfo::sock, t, and GNUNET_SCHEDULER_Task::write_fd.
Referenced by add_without_sets(), and GNUNET_SCHEDULER_add_select().
|
static |
calls the given function func on each FdInfo related to t.
Optionally updates the event type field in each FdInfo after calling func.
t | the task |
driver_func | the function to call with each FdInfo contained in in t |
if_not_ready | only call driver_func on FdInfos that are not ready |
et | the event type to be set in each FdInfo after calling driver_func on it, or -1 if no updating not desired. |
Definition at line 914 of file scheduler.c.
References GNUNET_SCHEDULER_Driver::add, GNUNET_SCHEDULER_Driver::cls, GNUNET_SCHEDULER_FdInfo::et, GNUNET_SCHEDULER_Task::fds, GNUNET_SCHEDULER_Task::fds_len, GNUNET_ERROR_TYPE_ERROR, GNUNET_SCHEDULER_ET_NONE, GNUNET_YES, LOG, scheduler_driver, and t.
Referenced by add_without_sets(), and GNUNET_SCHEDULER_add_select().
|
static |
Definition at line 936 of file scheduler.c.
References GNUNET_OS_install_parent_control_handler(), and install_parent_control_task.
Referenced by GNUNET_SCHEDULER_driver_init().
|
static |
Definition at line 945 of file scheduler.c.
References GNUNET_assert, GNUNET_DISK_file_read(), GNUNET_DISK_handle_invalid(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_UNIT_FOREVER_REL, shutdown_pipe_cb(), shutdown_pipe_handle, and shutdown_pipe_task.
Referenced by GNUNET_SCHEDULER_driver_init(), and shutdown_pipe_cb().
|
static |
Initialize backtrace data for task t.
t | task to initialize |
Definition at line 1046 of file scheduler.c.
References dump_backtrace(), and t.
Referenced by add_without_sets(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_shutdown(), and GNUNET_SCHEDULER_add_with_reason_and_priority().
|
static |
Schedule a new task to be run with a specified delay or when any of the specified file descriptor sets is ready.
The delay can be used as a timeout on the socket(s) being ready. The task will be scheduled for execution once either the delay has expired or any of the socket operations is ready. This is the most general function of the "add" family. Note that the "prerequisite_task" must be satisfied in addition to any of the other conditions. In other words, the task will be started when (prerequisite-run) && (delay-ready || any-rs-ready || any-ws-ready)
delay | how long should we wait? |
priority | priority to use |
rfd | file descriptor we want to read (can be -1) |
wfd | file descriptors we want to write (can be -1) |
task | main function of the task |
task_cls | closure of task |
Definition at line 1439 of file scheduler.c.
References GNUNET_SCHEDULER_Task::callback, GNUNET_SCHEDULER_Task::callback_cls, check_priority(), current_lifeness, current_priority, driver_add_multiple(), GNUNET_DISK_FileHandle::fd, GNUNET_assert, GNUNET_async_scope_get(), GNUNET_CONTAINER_DLL_insert, GNUNET_MAX, GNUNET_NETWORK_get_fd(), GNUNET_new, GNUNET_SCHEDULER_PRIORITY_KEEP, GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_to_absolute(), init_backtrace(), init_fd_info(), GNUNET_SCHEDULER_Task::lifeness, max_priority_added, pending_head, pending_tail, GNUNET_SCHEDULER_Task::priority, scheduler_driver, GNUNET_SCHEDULER_Task::scope, t, and GNUNET_SCHEDULER_Task::timeout.
Referenced by GNUNET_SCHEDULER_add_file_with_priority(), and GNUNET_SCHEDULER_add_net_with_priority().
|
static |
Definition at line 1753 of file scheduler.c.
References GNUNET_array_append, GNUNET_assert, GNUNET_DISK_get_handle_from_int_fd(), GNUNET_NETWORK_fdset_test_native(), GNUNET_NETWORK_socket_box_native(), GNUNET_YES, and GNUNET_NETWORK_FDSet::nsds.
Referenced by GNUNET_SCHEDULER_add_select().
|
static |
Definition at line 2469 of file scheduler.c.
References context, GNUNET_SCHEDULER_FdInfo::et, Scheduled::et, GNUNET_SCHEDULER_FdInfo::fd, Scheduled::fdi, GNUNET_SCHEDULER_FdInfo::fh, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_ET_IN, GNUNET_SCHEDULER_ET_OUT, GNUNET_SYSERR, GNUNET_SCHEDULER_FdInfo::sock, and Scheduled::task.
Referenced by GNUNET_SCHEDULER_driver_select().
|
static |
Definition at line 2501 of file scheduler.c.
References context, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, GNUNET_SYSERR, Scheduled::next, ret, and Scheduled::task.
Referenced by GNUNET_SCHEDULER_driver_select().
|
static |
Definition at line 2531 of file scheduler.c.
References context, and GNUNET_assert.
Referenced by GNUNET_SCHEDULER_driver_select().
|
static |
Placed at the end of a ready queue to indicate where a scheduler run pass ends.
The next, prev, in_ready_list and priority fields are the only ones that should be used.
Definition at line 256 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_get_load(), remove_pass_end_marker(), and set_work_priority().
|
static |
The driver used for the event loop.
Will be handed over to the scheduler in GNUNET_SCHEDULER_do_work(), persisted there in this variable for later use in functions like GNUNET_SCHEDULER_add_select(), add_without_sets() and GNUNET_SCHEDULER_cancel().
Definition at line 319 of file scheduler.c.
Referenced by add_without_sets(), driver_add_multiple(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_file_with_priority(), GNUNET_SCHEDULER_add_net_with_priority(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_driver_done(), and GNUNET_SCHEDULER_driver_init().
|
static |
Head of list of tasks waiting for an event.
Definition at line 324 of file scheduler.c.
Referenced by add_without_sets(), get_timeout(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_driver_done(), GNUNET_SCHEDULER_task_ready(), and shutdown_if_no_lifeness().
|
static |
Tail of list of tasks waiting for an event.
Definition at line 329 of file scheduler.c.
Referenced by add_without_sets(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_do_work(), and GNUNET_SCHEDULER_task_ready().
|
static |
Head of list of tasks waiting for shutdown.
Definition at line 334 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_driver_done(), GNUNET_SCHEDULER_shutdown(), and shutdown_if_no_lifeness().
|
static |
Tail of list of tasks waiting for shutdown.
Definition at line 339 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_cancel(), and GNUNET_SCHEDULER_shutdown().
|
static |
List of tasks waiting ONLY for a timeout event.
Sorted by timeout (earliest first). Used so that we do not traverse the list of these tasks when building select sets (we just look at the head to determine the respective timeout ONCE).
Definition at line 348 of file scheduler.c.
Referenced by get_timeout(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_driver_done(), select_loop(), and shutdown_if_no_lifeness().
|
static |
List of tasks waiting ONLY for a timeout event.
Sorted by timeout (earliest first). Used so that we do not traverse the list of these tasks when building select sets (we just look at the head to determine the respective timeout ONCE).
Definition at line 357 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_cancel(), and GNUNET_SCHEDULER_do_work().
|
static |
Last inserted task waiting ONLY for a timeout event.
Used to (heuristically) speed up insertion.
Definition at line 363 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_cancel(), and GNUNET_SCHEDULER_do_work().
|
static |
ID of the task that is running right now.
Definition at line 368 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_begin_async_scope(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_get_load(), and GNUNET_SCHEDULER_get_task_context().
|
static |
Head of list of tasks ready to run right now, grouped by importance.
Definition at line 374 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_driver_done(), GNUNET_SCHEDULER_get_load(), queue_ready_task(), remove_pass_end_marker(), and set_work_priority().
|
static |
Tail of list of tasks ready to run right now, grouped by importance.
Definition at line 380 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_do_work(), queue_ready_task(), remove_pass_end_marker(), and set_work_priority().
|
static |
Task for installing parent control handlers (it might happen that the scheduler is shutdown before this task is executed, so GNUNET_SCHEDULER_shutdown must cancel it in that case)
Definition at line 387 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_driver_init(), GNUNET_SCHEDULER_shutdown(), and install_parent_control_handler().
|
static |
Task for reading from a pipe that signal handlers will use to initiate shutdown.
Definition at line 393 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_driver_init(), GNUNET_SCHEDULER_shutdown(), and shutdown_pipe_cb().
|
static |
Number of tasks on the ready list.
Definition at line 398 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_get_load(), queue_ready_task(), select_loop(), and shutdown_if_no_lifeness().
|
static |
Priority of the task running right now.
Only valid while a task is running.
Definition at line 404 of file scheduler.c.
Referenced by add_without_sets(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_driver_init(), and GNUNET_SCHEDULER_get_load().
|
static |
Priority of the highest task added in the current select iteration.
Definition at line 410 of file scheduler.c.
Referenced by add_without_sets(), GNUNET_SCHEDULER_add_select(), and GNUNET_SCHEDULER_do_work().
|
static |
Value of the 'lifeness' flag for the current task.
Definition at line 415 of file scheduler.c.
Referenced by add_without_sets(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SCHEDULER_do_work(), and GNUNET_SCHEDULER_driver_init().
|
static |
Priority used currently in GNUNET_SCHEDULER_do_work().
Definition at line 420 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_do_work(), queue_ready_task(), and set_work_priority().
|
static |
Function to use as a select() in the scheduler.
If NULL, we use GNUNET_NETWORK_socket_select().
Definition at line 426 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_set_select(), and select_loop().
|
static |
Task context of the current task.
Definition at line 431 of file scheduler.c.
Referenced by check_add_address(), check_add_queue_message(), check_client_send(), check_communicator_available(), check_incoming_msg(), client_connect_cb(), client_disconnect_cb(), client_send_response(), cmd_read(), connect_probe_continuation(), core_send_connect_info(), cores_send_connect_info(), cores_send_disconnect_info(), create_address_entry(), decrypt_and_check_tc(), do_read(), do_s5r_read(), do_udp_read(), finish_handling_raw_message(), free_address_list_entry(), free_pending_message(), free_queue(), free_queue_entry(), free_timedout_queue_entry(), GNUNET_FS_share_tree_trim(), GNUNET_SCHEDULER_do_work(), GNUNET_SCHEDULER_get_task_context(), handle_add_address(), handle_add_queue_message(), handle_backchannel_encapsulation(), handle_client_recv_ok(), handle_client_send(), handle_client_start(), handle_communicator_available(), handle_communicator_backchannel(), handle_del_address(), handle_del_queue_message(), handle_incoming_msg(), handle_monitor_start(), handle_queue_create_fail(), handle_queue_create_ok(), handle_request_hello_validation(), handle_send_message_ack(), handle_suggest(), handle_suggest_cancel(), handle_update_queue_message(), lookup_communicator(), maint_child_death(), migrate_and_drop_keywords(), migrate_and_drop_metadata(), notify_client_connect_info(), notify_client_queues(), notify_monitor(), notify_monitors(), proto_read_kx(), queue_read_kx(), queue_send_msg(), read_dns4(), read_dns6(), read_response(), remove_high_frequency_keywords(), share_tree_trim(), shutdown_task(), start_burst(), stop_peer_request(), suggest_to_connect(), tcp_send(), tokenized_cb(), and transmit_kx().
|
static |
Closure for scheduler_select.
Definition at line 436 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_set_select(), and select_loop().
|
static |
Pipe used to communicate shutdown via signal.
Definition at line 660 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_driver_done(), GNUNET_SCHEDULER_driver_init(), shutdown_pipe_cb(), and sighandler_shutdown().
|
static |
Process ID of this process at the time we installed the various signal handlers.
Definition at line 666 of file scheduler.c.
Referenced by GNUNET_SCHEDULER_driver_init(), and sighandler_shutdown().