1 /* $NetBSD: job.h,v 1.2 2025/01/26 16:25:41 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 /*! \file isc/job.h 17 * \brief The isc_job unit provides a way to schedule jobs on the 18 * currently running isc event loop. This is distinct from isc_async, 19 * which can be used to send events to another, specified loop. 20 * 21 * The unit is built around the uv_idle_t primitive and it directly schedules 22 * the callback to be run on the isc event loop. 23 */ 24 25 #pragma once 26 27 #include <inttypes.h> 28 29 #include <isc/lang.h> 30 #include <isc/mem.h> 31 #include <isc/refcount.h> 32 #include <isc/types.h> 33 #include <isc/urcu.h> 34 35 typedef void (*isc_job_cb)(void *); 36 typedef struct isc_job isc_job_t; 37 38 struct isc_job { 39 isc_job_cb cb; 40 void *cbarg; 41 union { 42 struct cds_wfcq_node wfcq_node; 43 ISC_LINK(isc_job_t) link; 44 }; 45 }; 46 47 #define ISC_JOB_INITIALIZER \ 48 { \ 49 .link = ISC_LINK_INITIALIZER, \ 50 } 51 52 ISC_LANG_BEGINDECLS 53 54 void 55 isc_job_run(isc_loop_t *loop, isc_job_t *job, isc_job_cb cb, void *cbarg); 56 /*%< 57 * Schedule the job callback 'cb' to be run on the currently 58 * running event loop. 59 * 60 * Requires: 61 * 62 *\li 'loop' is the current loop 63 *\li 'job' is initialized 64 *\li 'cb' is a callback function, must be non-NULL 65 *\li 'cbarg' is passed to the 'cb' as the only argument, may be NULL 66 */ 67 68 ISC_LANG_ENDDECLS 69