aboutsummaryrefslogtreecommitdiffstats
path: root/libparc/parc/algol/internal_parc_Event.h
blob: ab157a56e087e8227c96541828b2da8c7c2c0201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file parc_EventQueue.h
 * @ingroup events
 * @brief Queue buffer events
 *
 * Provides a facade implementing many regularly available event functions.
 * This is an interface that software implementors may use to substitute
 * different kinds of underlying implementations of these event management functions.
 * Notable examples are libevent and libev.
 *
 */
#ifndef libparc_internal_parc_Event_h
#define libparc_internal_parc_Event_h

#include <parc/algol/parc_EventScheduler.h>
#include <parc/algol/parc_EventQueue.h>

/**
 * Map alloc() method call to a PARC internal memory method
 *
 * @param [in] size of memory to allocate
 * @returns NULL on error, memory pointer on success.
 *
 * Example:
 * @code
 * {
 *     return internal_parc_alloc(1024);
 * }
 * @endcode
 *
 */
void *internal_parc_alloc(size_t size);

/**
 * Map realloc() method call to a PARC internal memory method
 *
 * @param [in] pointer to memory to reallocate
 * @param [in] newSize of memory to allocate
 * @returns NULL on error, new memory pointer on success.
 *
 * Example:
 * @code
 * {
 *     return internal_parc_realloc(ptr, 2048);
 * }
 * @endcode
 *
 */
void *internal_parc_realloc(void *pointer, size_t newSize);

/**
 * Map free() method call to a PARC internal memory method
 *
 * @param [in] pointer to memory to free
 *
 * Example:
 * @code
 * {
 *     internal_parc_free(ptr);
 * }
 * @endcode
 *
 */
void internal_parc_free(void *ptr);

/**
 * Verify and initialize libevent
 *
 * Example:
 * @code
 * {
 *     internal_parc_initializeLibevent();
 * }
 * @endcode
 *
 */
void internal_parc_initializeLibevent(void);

/**
 * Convert from/to libevent dispatcher options and PARCEventSchedulerDispatcherType options.
 *
 * Example:
 * @code
 * {
 *     PARCEventSchedulerDispatchType type = internal_eventloop_options_to_PARCEventSchedulerDispatchType(EVLOOP_ONCE);
 *     short evtype = internal_PARCEventSchedulerDispatchType_to_eventloop_options(PARCEventSchedulerDispatchType_LoopOnce);
 * }
 * @endcode
 *
 */
PARCEventSchedulerDispatchType internal_eventloop_options_to_PARCEventSchedulerDispatchType(short evoptions);
short internal_PARCEventSchedulerDispatchType_to_eventloop_options(PARCEventSchedulerDispatchType options);

/**
 * Convert from/to libevent bufferevent options and PARCEventQueueOption.
 *
 * Example:
 * @code
 * {
 *     PARCEventQueueOption parcEventQueueOption = internal_bufferevent_options_to_PARCEventQueueOption(BEV_OPT_CLOSE_ON_FREE);
 *     short buffereventOption = internal_PARCEventQueueOption_to_bufferevent_options(PARCEventQueueOption_CloseOnFree);
 * }
 * @endcode
 *
 */
PARCEventQueueOption internal_bufferevent_options_to_PARCEventQueueOption(short evflags);
short internal_PARCEventQueueOption_to_bufferevent_options(PARCEventQueueOption flags);

/**
 * Convert from/to libevent bufferevent types and PARCEventQueueEventType.
 *
 * Example:
 * @code
 * {
 *     PARCEventQueueEventType parcEventQueueEventType = internal_bufferevent_type_to_PARCEventQueueEventType(BEV_EVENT_READING);
 *     short buffereventOptions = internal_PARCEventQueueEventType_to_bufferevent_type(PARCEventQueueEventType_Reading);
 * }
 * @endcode
 *
 */
PARCEventQueueEventType internal_bufferevent_type_to_PARCEventQueueEventType(short evtypes);
short internal_PARCEventQueueEventType_to_bufferevent_type(PARCEventQueueEventType types);

/**
 * Convert from/to libevent event types and PARCEventType.
 *
 * Example:
 * @code
 * {
 *     PARCEventType parcEventType = internal_libevent_type_to_PARCEventType(EV_READ);
 *     short buffereventOptions = internal_PARCEventType_to_libevent_type(PARCEventType_Read);
 * }
 * @endcode
 *
 */
PARCEventType internal_libevent_type_to_PARCEventType(short evtypes);
short internal_PARCEventType_to_libevent_type(PARCEventType types);

/**
 * Convert from/to libevent priority types and PARCEventPriority.
 *
 * Example:
 * @code
 * {
 *     PARCEventPriority parcEventPriority = internal_libevent_priority_to_PARCEventPriority(0);
 *     short priority = internal_PARCEventPriority_to_libevent_priority(PARCEventPriority_Normal);
 * }
 * @endcode
 *
 */
short internal_PARCEventPriority_to_libevent_priority(PARCEventPriority priority);
PARCEventPriority internal_libevent_priority_to_PARCEventPriority(short evpriority);
#endif // libparc_internal_parc_Event_h