xref: /netbsd-src/external/bsd/libevent/dist/defer-internal.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*	$NetBSD: defer-internal.h,v 1.1.1.2 2017/01/31 21:14:52 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 void event_deferred_cb_init_(struct event_callback *, ev_uint8_t, deferred_cb_fn, void *);
51 /**
52    Change the priority of a non-pending event_callback.
53  */
54 void event_deferred_cb_set_priority_(struct event_callback *, ev_uint8_t);
55 /**
56    Cancel a struct event_callback if it is currently scheduled in an event_base.
57  */
58 void event_deferred_cb_cancel_(struct event_base *, struct event_callback *);
59 /**
60    Activate a struct event_callback if it is not currently scheduled in an event_base.
61 
62    Return true if it was not previously scheduled.
63  */
64 int event_deferred_cb_schedule_(struct event_base *, struct event_callback *);
65 
66 #ifdef __cplusplus
67 }
68 #endif
69 
70 #endif /* EVENT_INTERNAL_H_INCLUDED_ */
71 
72