Function gnunet_sys::GNUNET_SCHEDULER_driver_init[][src]

pub unsafe extern "C" fn GNUNET_SCHEDULER_driver_init(
    driver: *const GNUNET_SCHEDULER_Driver
) -> *mut GNUNET_SCHEDULER_Handle

Function called by external event loop implementations to initialize the scheduler. An external implementation has to provide @a driver which contains callbacks for the scheduler (see definition of struct #GNUNET_SCHEDULER_Driver). The callbacks are used to instruct the external implementation to watch for events. If it detects any of those events it is expected to call #GNUNET_SCHEDULER_do_work to let the scheduler handle it. If an event is related to a specific task (e.g. the scheduler gave instructions to watch a file descriptor), the external implementation is expected to mark that task ready before by calling #GNUNET_SCHEDULER_task_ready.

This function has to be called before any tasks are scheduled and before GNUNET_SCHEDULER_do_work is called for the first time. It allocates resources that have to be freed again by calling #GNUNET_SCHEDULER_driver_done.

This function installs the same signal handlers as #GNUNET_SCHEDULER_run. This means SIGTERM (and other similar signals) will induce a call to #GNUNET_SCHEDULER_shutdown during the next call to #GNUNET_SCHEDULER_do_work. As a result, SIGTERM causes all active tasks to be scheduled with reason #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added afterwards will execute normally!). Note that any particular signal will only shut down one scheduler; applications should always only create a single scheduler.

@param driver to use for the event loop @return handle to be passed to #GNUNET_SCHEDULER_do_work and #GNUNET_SCHEDULER_driver_done