2 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2002 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: event.h,v 1.34 2007/06/19 23:47:18 tbox Exp $ */
23 /*! \file isc/event.h */
26 #include <isc/types.h>
32 typedef void (*isc_eventdestructor_t)(isc_event_t *);
34 #define ISC_EVENT_COMMON(ltype) \
36 unsigned int ev_attributes; \
38 isc_eventtype_t ev_type; \
39 isc_taskaction_t ev_action; \
42 isc_eventdestructor_t ev_destroy; \
43 void * ev_destroy_arg; \
44 ISC_LINK(ltype) ev_link
47 * Attributes matching a mask of 0x000000ff are reserved for the task library's
48 * definition. Attributes of 0xffffff00 may be used by the application
49 * or non-ISC libraries.
51 #define ISC_EVENTATTR_NOPURGE 0x00000001
54 * The ISC_EVENTATTR_CANCELED attribute is intended to indicate
55 * that an event is delivered as a result of a canceled operation
56 * rather than successful completion, by mutual agreement
57 * between the sender and receiver. It is not set or used by
60 #define ISC_EVENTATTR_CANCELED 0x00000002
62 #define ISC_EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da) \
64 (event)->ev_size = (sz); \
65 (event)->ev_attributes = (at); \
66 (event)->ev_tag = (ta); \
67 (event)->ev_type = (ty); \
68 (event)->ev_action = (ac); \
69 (event)->ev_arg = (ar); \
70 (event)->ev_sender = (sn); \
71 (event)->ev_destroy = (df); \
72 (event)->ev_destroy_arg = (da); \
73 ISC_LINK_INIT((event), ev_link); \
77 * This structure is public because "subclassing" it may be useful when
78 * defining new event types.
81 ISC_EVENT_COMMON(struct isc_event);
84 #define ISC_EVENTTYPE_FIRSTEVENT 0x00000000
85 #define ISC_EVENTTYPE_LASTEVENT 0xffffffff
87 #define ISC_EVENT_PTR(p) ((isc_event_t **)(void *)(p))
92 isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
93 isc_taskaction_t action, const void *arg, size_t size);
95 * Allocate an event structure.
97 * Allocate and initialize in a structure with initial elements
102 * ISC_EVENT_COMMON(struct isc_event);
108 *\li 'size' >= sizeof(struct isc_event)
109 *\li 'action' to be non NULL
112 *\li a pointer to a initialized structure of the requested size.
113 *\li NULL if unable to allocate memory.
117 isc_event_free(isc_event_t **);
121 #endif /* ISC_EVENT_H */