TizenRT Public API  v2.0 M2
eventloop.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2018 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
27 #ifndef __EVENTLOOP_H__
28 #define __EVENTLOOP_H__
29 
30 #include <libtuv/uv.h>
31 #include <stdbool.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36 
42  EVENTLOOP_INVALID_PARAM = -1,
43  EVENTLOOP_BUSY = -2,
44  EVENTLOOP_OUT_OF_MEMORY = -3,
45  EVENTLOOP_LOOP_FAIL = -4,
46  EVENTLOOP_NOT_FINISHED = -5,
47  EVENTLOOP_OPERATION_FAIL = -6,
48  EVENTLOOP_INVALID_HANDLE = -7,
49 };
50 
65  EL_EVENT_WIFI_ON = 1,
66  EL_EVENT_WIFI_OFF = 2,
67  EL_EVENT_MAX,
68 };
69 
78 #define EVENTLOOP_CALLBACK_STOP 0
79 #define EVENTLOOP_CALLBACK_CONTINUE 1
80 
84 typedef uv_timer_t el_timer_t;
85 
89 typedef uv_loop_t el_loop_t;
90 
94 typedef uv_signal_t el_event_t;
95 
99 typedef bool (*timeout_callback)(void *data);
100 
104 typedef void (*thread_safe_callback)(void *data);
105 
113 typedef bool (*event_callback)(void *registered_cb_data, void *received_event_data);
114 
115 /****************************************************************************
116  * Public Function Prototypes
117  ****************************************************************************/
118 
139 el_timer_t *eventloop_add_timer(unsigned int timeout, bool repeat, timeout_callback func, void *cb_data);
140 
149 int eventloop_delete_timer(el_timer_t *timer);
150 
172 el_timer_t *eventloop_add_timer_async(unsigned int timeout, bool repeat, timeout_callback func, void *cb_data);
173 
196 el_event_t *eventloop_add_event_handler(int type, event_callback func, void *cb_data);
197 
206 int eventloop_del_event_handler(el_event_t *handle);
207 
220 int eventloop_send_event(int type, void *event_data, int data_size);
221 
230 int eventloop_loop_run(void);
231 
239 int eventloop_loop_stop(void);
240 
252 
253 #ifdef __cplusplus
254 }
255 #endif /* __cplusplus */
256 
257 #endif
258 
el_event_type_e
Event type used in Event Loop.
Definition: eventloop.h:64
uv_signal_t el_event_t
EventLoop Event structure.
Definition: eventloop.h:94
int eventloop_loop_run(void)
Run the loop of its own task.
int eventloop_del_event_handler(el_event_t *handle)
Delete registered handler for event.
bool(* timeout_callback)(void *data)
EventLoop Timeout Callback.
Definition: eventloop.h:99
el_result_error_e
Error Type of Result Value returned from Event Loop.
Definition: eventloop.h:41
int eventloop_delete_timer(el_timer_t *timer)
Delete specific timer.
uv_timer_t el_timer_t
EventLoop Timer structure.
Definition: eventloop.h:84
int eventloop_thread_safe_function_call(thread_safe_callback func, void *cb_data)
Callback is added at the each eventloop to be called thread safely. .
int eventloop_loop_stop(void)
Stop the loop of its own task.
el_timer_t * eventloop_add_timer(unsigned int timeout, bool repeat, timeout_callback func, void *cb_data)
Create timer to call the function in the given period of time.
void(* thread_safe_callback)(void *data)
EventLoop Thread Safe Callback.
Definition: eventloop.h:104
el_event_t * eventloop_add_event_handler(int type, event_callback func, void *cb_data)
Set event callback which will be called a certain event occur.
int eventloop_send_event(int type, void *event_data, int data_size)
Send an event.
el_timer_t * eventloop_add_timer_async(unsigned int timeout, bool repeat, timeout_callback func, void *cb_data)
Create timer to call the function in the given period of time asynchronously.
uv_loop_t el_loop_t
EventLoop Loop structure.
Definition: eventloop.h:89
bool(* event_callback)(void *registered_cb_data, void *received_event_data)
EventLoop Event Callback This is specific type for callback function used in eventloop_add_event_hand...
Definition: eventloop.h:113