facil.io

#./fio-stl/004 state callbacks.h

4 public symbols.

#Types

#fio_state_event_type_e

c
typedef enum {
/** Called once during library initialization. */
FIO_CALL_ON_INITIALIZE,
/** Called once before starting up the IO reactor. */
FIO_CALL_PRE_START,
/** Called before forking starts for a worker group. */
FIO_CALL_BEFORE_FORK,
/** Called by a child worker process right after it was forked. */
FIO_CALL_IN_CHILD,
/** Called by the master process right after spawning a worker. */
FIO_CALL_IN_MASTER,
/** Called after forking ends for a worker group. */
FIO_CALL_AFTER_FORK,
/** Called by each worker thread in a Server Async queue as it starts. */
FIO_CALL_ON_WORKER_THREAD_START,
/** Called every time a *Worker* process starts. */
FIO_CALL_ON_START,
/** Reserved for internal use. */
FIO_CALL_RESERVED1,
/** Reserved for internal use. */
FIO_CALL_RESERVED2,
/** User state event queue (unused, available for the user). */
FIO_CALL_ON_USER1,
/** User state event queue (unused, available for the user). */
FIO_CALL_ON_USER2,
/** Called when facil.io enters idling mode. */
FIO_CALL_ON_IDLE,
/** A reversed user state event queue (unused, available for the user). */
FIO_CALL_ON_USER1_REVERSE,
/** A reversed user state event queue (unused, available for the user). */
FIO_CALL_ON_USER2_REVERSE,
/** Reserved for internal use. */
FIO_CALL_RESERVED1_REVERSED,
/** Reserved for internal use. */
FIO_CALL_RESERVED2_REVERSED,
/** Called before starting the shutdown sequence. */
FIO_CALL_ON_SHUTDOWN,
/** Called by each worker the moment it detects the master process crashed. */
FIO_CALL_ON_PARENT_CRUSH,
/** Called by the parent (master) after a worker process crashed. */
FIO_CALL_ON_CHILD_CRUSH,
/** Called by each worker thread in a Server Async queue as it ends. */
FIO_CALL_ON_WORKER_THREAD_END,
/** Called when wither a *Worker* or *Master* stopped. */
FIO_CALL_ON_STOP,
/** An alternative to the system's at_exit. */
FIO_CALL_AT_EXIT,
/** Use after cleanup (e.g., leak testing). */
FIO_CALL_AFTER_EXIT,
/** used for testing and array allocation - must be last. */
FIO_CALL_NEVER
} fio_state_event_type_e

a callback type enum

Symbol type: type

#Functions

#fio_state_callback_add

c
void fio_state_callback_add(fio_state_event_type_e, void (*func)(void *), void *arg)

Adds a callback to the list of callbacks to be called for the event.

Symbol type: function

#fio_state_callback_remove

c
int fio_state_callback_remove(fio_state_event_type_e, void (*func)(void *), void *arg)

Removes a callback from the list of callbacks to be called for the event.

Symbol type: function

#fio_state_callback_force

c
void fio_state_callback_force(fio_state_event_type_e)

Forces all the existing callbacks to run, as if the event occurred.

Callbacks for all initialization / idling tasks are called in order of creation (where fio_state_event_type_e <= FIO_CALL_ON_IDLE).

Callbacks for all cleanup oriented tasks are called in reverse order of creation (where fio_state_event_type_e >= FIO_CALL_ON_SHUTDOWN).

During an event, changes to the callback list are ignored (callbacks can't add or remove other callbacks for the same event).

Symbol type: function