Add asynchronous work API to the network manager
The libuv has a support for running long running tasks in the dedicated threadpools, so it doesn't affect networking IO. This commit adds isc_nm_work_enqueue() wrapper that would wraps around the libuv API and runs it on top of associated worker loop. The only limitation is that the function must be called from inside network manager thread, so the call to the function should be wrapped inside a (bound) task.
This commit is contained in:
@@ -68,6 +68,12 @@ typedef void (*isc_nm_opaquecb_t)(void *arg);
|
||||
* callbacks.
|
||||
*/
|
||||
|
||||
typedef void (*isc_nm_workcb_t)(void *arg);
|
||||
typedef void (*isc_nm_after_workcb_t)(void *arg, isc_result_t result);
|
||||
/*%<
|
||||
* Callback functions for libuv threadpool work (see uv_work_t)
|
||||
*/
|
||||
|
||||
void
|
||||
isc_nm_attach(isc_nm_t *mgr, isc_nm_t **dst);
|
||||
void
|
||||
@@ -529,6 +535,19 @@ isc_nm_task_enqueue(isc_nm_t *mgr, isc_task_t *task, int threadid);
|
||||
* maximum number of 'workers' as specifed in isc_nm_start()
|
||||
*/
|
||||
|
||||
void
|
||||
isc_nm_work_offload(isc_nm_t *mgr, isc_nm_workcb_t work_cb,
|
||||
isc_nm_after_workcb_t after_work_cb, void *data);
|
||||
/*%<
|
||||
* Schedules a job to be handled by the libuv thread pool (see uv_work_t).
|
||||
* The function specified in `work_cb` will be run by a thread in the
|
||||
* thread pool; when complete, the `after_work_cb` function will run.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'mgr' is a valid netmgr object.
|
||||
* \li We are currently running in a network manager thread.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__nm_force_tid(int tid);
|
||||
/*%<
|
||||
|
||||
Reference in New Issue
Block a user