xref: /netbsd-src/external/bsd/libevent/dist/defer-internal.h (revision 657871a79c9a2060a6255a242fa1a1ef76b56ec6)
1 /*	$NetBSD: defer-internal.h,v 1.1.1.3 2021/04/07 02:43:14 christos Exp $	*/
2 /*
3  * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  *    derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 #ifndef DEFER_INTERNAL_H_INCLUDED_
28 #define DEFER_INTERNAL_H_INCLUDED_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include "event2/event-config.h"
35 #include "evconfig-private.h"
36 
37 #include <sys/queue.h>
38 
39 struct event_callback;
40 typedef void (*deferred_cb_fn)(struct event_callback *, void *);
41 
42 /**
43    Initialize an empty, non-pending event_callback.
44 
45    @param deferred The struct event_callback structure to initialize.
46    @param priority The priority that the callback should run at.
47    @param cb The function to run when the struct event_callback executes.
48    @param arg The function's second argument.
49  */
50 EVENT2_EXPORT_SYMBOL
51 void event_deferred_cb_init_(struct event_callback *, ev_uint8_t, deferred_cb_fn, void *);
52 /**
53    Change the priority of a non-pending event_callback.
54  */
55 void event_deferred_cb_set_priority_(struct event_callback *, ev_uint8_t);
56 /**
57    Cancel a struct event_callback if it is currently scheduled in an event_base.
58  */
59 EVENT2_EXPORT_SYMBOL
60 void event_deferred_cb_cancel_(struct event_base *, struct event_callback *);
61 /**
62    Activate a struct event_callback if it is not currently scheduled in an event_base.
63 
64    Return true if it was not previously scheduled.
65  */
66 EVENT2_EXPORT_SYMBOL
67 int event_deferred_cb_schedule_(struct event_base *, struct event_callback *);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif /* EVENT_INTERNAL_H_INCLUDED_ */
74 
75