Previously, isc_job_run() could have been used to run the job on the current loop and the isc_job_run() would take care of allocating and deallocating the job. After the change in this MR, the isc_job_run() is more complicated to use, so we introduce the isc_async_current() macro to suplement isc_async_run() when we need to run the job on the current loop.
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
/*
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
*
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
* information regarding copyright ownership.
|
|
*/
|
|
|
|
/*! \file isc/async.h
|
|
* \brief The isc_async unit provides a way to schedule jobs on any isc
|
|
* event loop (isc_loop unit)
|
|
*
|
|
* The unit is built around the uv_async_t primitive and lock-free stack with
|
|
* isc_job_cb. Jobs are first scheduled onto the locked list, then the
|
|
* uv_async_send() is called and the uv_async_t callback processes the enqueued
|
|
* jobs are scheduled to be run on the isc event loop.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <isc/job.h>
|
|
#include <isc/lang.h>
|
|
#include <isc/loop.h>
|
|
#include <isc/mem.h>
|
|
#include <isc/types.h>
|
|
|
|
ISC_LANG_BEGINDECLS
|
|
|
|
void
|
|
isc_async_run(isc_loop_t *loop, isc_job_cb cb, void *cbarg);
|
|
/*%<
|
|
* Schedule the job callback 'cb' to be run on the 'loop' event loop.
|
|
*
|
|
* Requires:
|
|
*
|
|
*\li 'loop' is a valid isc event loop
|
|
*\li 'cb' is a callback function, must be non-NULL
|
|
*\li 'cbarg' is passed to the 'cb' as the only argument, may be NULL
|
|
*/
|
|
|
|
#define isc_async_current(loopmgr, cb, cbarg) \
|
|
isc_async_run(isc_loop_current(loopmgr), cb, cbarg)
|
|
/*%<
|
|
* Helper macro to run the job on the current loop
|
|
*/
|
|
|
|
ISC_LANG_ENDDECLS
|