1*657871a7Schristos /* $NetBSD: defer-internal.h,v 1.1.1.3 2021/04/07 02:43:14 christos Exp $ */ 26ecf6635Schristos /* 36ecf6635Schristos * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson 46ecf6635Schristos * 56ecf6635Schristos * Redistribution and use in source and binary forms, with or without 66ecf6635Schristos * modification, are permitted provided that the following conditions 76ecf6635Schristos * are met: 86ecf6635Schristos * 1. Redistributions of source code must retain the above copyright 96ecf6635Schristos * notice, this list of conditions and the following disclaimer. 106ecf6635Schristos * 2. Redistributions in binary form must reproduce the above copyright 116ecf6635Schristos * notice, this list of conditions and the following disclaimer in the 126ecf6635Schristos * documentation and/or other materials provided with the distribution. 136ecf6635Schristos * 3. The name of the author may not be used to endorse or promote products 146ecf6635Schristos * derived from this software without specific prior written permission. 156ecf6635Schristos * 166ecf6635Schristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 176ecf6635Schristos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 186ecf6635Schristos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 196ecf6635Schristos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 206ecf6635Schristos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 216ecf6635Schristos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 226ecf6635Schristos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 236ecf6635Schristos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 246ecf6635Schristos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 256ecf6635Schristos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 266ecf6635Schristos */ 27805a1ce9Schristos #ifndef DEFER_INTERNAL_H_INCLUDED_ 28805a1ce9Schristos #define DEFER_INTERNAL_H_INCLUDED_ 296ecf6635Schristos 306ecf6635Schristos #ifdef __cplusplus 316ecf6635Schristos extern "C" { 326ecf6635Schristos #endif 336ecf6635Schristos 346ecf6635Schristos #include "event2/event-config.h" 35805a1ce9Schristos #include "evconfig-private.h" 36805a1ce9Schristos 376ecf6635Schristos #include <sys/queue.h> 386ecf6635Schristos 39805a1ce9Schristos struct event_callback; 40805a1ce9Schristos typedef void (*deferred_cb_fn)(struct event_callback *, void *); 416ecf6635Schristos 426ecf6635Schristos /** 43805a1ce9Schristos Initialize an empty, non-pending event_callback. 446ecf6635Schristos 45805a1ce9Schristos @param deferred The struct event_callback structure to initialize. 46805a1ce9Schristos @param priority The priority that the callback should run at. 47805a1ce9Schristos @param cb The function to run when the struct event_callback executes. 486ecf6635Schristos @param arg The function's second argument. 496ecf6635Schristos */ 50*657871a7Schristos EVENT2_EXPORT_SYMBOL 51805a1ce9Schristos void event_deferred_cb_init_(struct event_callback *, ev_uint8_t, deferred_cb_fn, void *); 526ecf6635Schristos /** 53805a1ce9Schristos Change the priority of a non-pending event_callback. 546ecf6635Schristos */ 55805a1ce9Schristos void event_deferred_cb_set_priority_(struct event_callback *, ev_uint8_t); 566ecf6635Schristos /** 57805a1ce9Schristos Cancel a struct event_callback if it is currently scheduled in an event_base. 586ecf6635Schristos */ 59*657871a7Schristos EVENT2_EXPORT_SYMBOL 60805a1ce9Schristos void event_deferred_cb_cancel_(struct event_base *, struct event_callback *); 61805a1ce9Schristos /** 62805a1ce9Schristos Activate a struct event_callback if it is not currently scheduled in an event_base. 636ecf6635Schristos 64805a1ce9Schristos Return true if it was not previously scheduled. 65805a1ce9Schristos */ 66*657871a7Schristos EVENT2_EXPORT_SYMBOL 67805a1ce9Schristos int event_deferred_cb_schedule_(struct event_base *, struct event_callback *); 686ecf6635Schristos 696ecf6635Schristos #ifdef __cplusplus 706ecf6635Schristos } 716ecf6635Schristos #endif 726ecf6635Schristos 73805a1ce9Schristos #endif /* EVENT_INTERNAL_H_INCLUDED_ */ 746ecf6635Schristos 75