14868f4d2SNick Mathewson /* 2e49e2891SNick Mathewson * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson 34868f4d2SNick Mathewson * 44868f4d2SNick Mathewson * Redistribution and use in source and binary forms, with or without 54868f4d2SNick Mathewson * modification, are permitted provided that the following conditions 64868f4d2SNick Mathewson * are met: 74868f4d2SNick Mathewson * 1. Redistributions of source code must retain the above copyright 84868f4d2SNick Mathewson * notice, this list of conditions and the following disclaimer. 94868f4d2SNick Mathewson * 2. Redistributions in binary form must reproduce the above copyright 104868f4d2SNick Mathewson * notice, this list of conditions and the following disclaimer in the 114868f4d2SNick Mathewson * documentation and/or other materials provided with the distribution. 124868f4d2SNick Mathewson * 3. The name of the author may not be used to endorse or promote products 134868f4d2SNick Mathewson * derived from this software without specific prior written permission. 144868f4d2SNick Mathewson * 154868f4d2SNick Mathewson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 164868f4d2SNick Mathewson * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 174868f4d2SNick Mathewson * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 184868f4d2SNick Mathewson * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 194868f4d2SNick Mathewson * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 204868f4d2SNick Mathewson * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 214868f4d2SNick Mathewson * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 224868f4d2SNick Mathewson * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 234868f4d2SNick Mathewson * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 244868f4d2SNick Mathewson * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 254868f4d2SNick Mathewson */ 263f8c7cd0SNick Mathewson #ifndef DEFER_INTERNAL_H_INCLUDED_ 273f8c7cd0SNick Mathewson #define DEFER_INTERNAL_H_INCLUDED_ 284868f4d2SNick Mathewson 294868f4d2SNick Mathewson #ifdef __cplusplus 304868f4d2SNick Mathewson extern "C" { 314868f4d2SNick Mathewson #endif 324868f4d2SNick Mathewson 33ec347b92SNick Mathewson #include "event2/event-config.h" 340915ca0aSKevin Bowling #include "evconfig-private.h" 350915ca0aSKevin Bowling 364868f4d2SNick Mathewson #include <sys/queue.h> 374868f4d2SNick Mathewson 38ae2b84b2SNick Mathewson struct event_callback; 39ae2b84b2SNick Mathewson typedef void (*deferred_cb_fn)(struct event_callback *, void *); 40b06b2649SNick Mathewson 41838d0a81SNick Mathewson /** 42a4079aa8SNick Mathewson Initialize an empty, non-pending event_callback. 43838d0a81SNick Mathewson 44a4079aa8SNick Mathewson @param deferred The struct event_callback structure to initialize. 45c0e425abSNick Mathewson @param priority The priority that the callback should run at. 46a4079aa8SNick Mathewson @param cb The function to run when the struct event_callback executes. 47838d0a81SNick Mathewson @param arg The function's second argument. 48838d0a81SNick Mathewson */ 49*9806b126SAzat Khuzhin EVENT2_EXPORT_SYMBOL 50c0e425abSNick Mathewson void event_deferred_cb_init_(struct event_callback *, ev_uint8_t, deferred_cb_fn, void *); 51c0e425abSNick Mathewson /** 52c0e425abSNick Mathewson Change the priority of a non-pending event_callback. 53c0e425abSNick Mathewson */ 54c0e425abSNick Mathewson void event_deferred_cb_set_priority_(struct event_callback *, ev_uint8_t); 55838d0a81SNick Mathewson /** 56a4079aa8SNick Mathewson Cancel a struct event_callback if it is currently scheduled in an event_base. 57838d0a81SNick Mathewson */ 58*9806b126SAzat Khuzhin EVENT2_EXPORT_SYMBOL 59ae2b84b2SNick Mathewson void event_deferred_cb_cancel_(struct event_base *, struct event_callback *); 60838d0a81SNick Mathewson /** 61a4079aa8SNick Mathewson Activate a struct event_callback if it is not currently scheduled in an event_base. 62b06b2649SNick Mathewson 6338cef641SGreg Hazel Return true if it was not previously scheduled. 64ae2b84b2SNick Mathewson */ 65*9806b126SAzat Khuzhin EVENT2_EXPORT_SYMBOL 66ae2b84b2SNick Mathewson int event_deferred_cb_schedule_(struct event_base *, struct event_callback *); 674868f4d2SNick Mathewson 684868f4d2SNick Mathewson #ifdef __cplusplus 694868f4d2SNick Mathewson } 704868f4d2SNick Mathewson #endif 714868f4d2SNick Mathewson 723f8c7cd0SNick Mathewson #endif /* EVENT_INTERNAL_H_INCLUDED_ */ 734868f4d2SNick Mathewson 74