int valvula_thread_pool_new_event ( ValvulaCtx ctx,
long  microseconds,
ValvulaThreadAsyncEvent  event_handler,
axlPointer  user_data,
axlPointer  user_data2 

Allows to install a new async event represented by the event handler provided.

This async event represents a handler called at the interval defined by microseconds, optionally refreshing that period if the event handler returns axl_false.

The event handler will be called after microseconds provided has expired. And if the handler returns axl_true (remove) the event will be cleared and called no more.

Note that events installed on this function must be tasks that aren't loops or takes too long to complete. This is because the thread pool asigns one thread to check and execute pending events, so, if one of those events delays, the rest won't be executed until the former finishes. In the case you want to install a loop handler or some handler that executes a long running code, then use valvula_thread_pool_new_task.

ctxThe ValvulaCtx context where the event will be installed. This is provided because event handlers are handled by the valvula thread pool. This parameter can't be NULL.
microsecondsThe amount of time to wait before calling to event handler. This value must be > 0.
event_handlerThe handler to be called after microseconds value has expired. This parameter can't be NULL.
user_dataUser defined pointer to data to be passed to the event handler.
user_data2Second user defined pointer to data to be passed to the event handler.
The method returns the event identifier. This identifier can be used to remove the event by using valvula_thread_pool_remove_event. The function returns -1 in case of failure.

References valvula_mutex_lock(), and valvula_mutex_unlock().

Referenced by valvulad_run_config().