FOSSology  4.4.0
Open Source License Compliance by Open Source Software
event.h
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2010, 2011, 2012 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
11 #ifndef EVENT_H_INCLUDE
12 #define EVENT_H_INCLUDE
13 
14 /* scheduler includes */
15 #include <scheduler.h>
16 
17 /* ************************************************************************** */
18 /* **** Data Types ********************************************************** */
19 /* ************************************************************************** */
20 
21 #define EVENT_LOOP_SIZE 1024
22 
24 typedef struct {
25  void(*func)(scheduler_t*, void*);
26  void* argument;
27  char* name;
28  char* source_name;
29  uint16_t source_line;
30 } event_t;
31 
33 typedef struct event_loop {
34  GAsyncQueue* queue;
35  int terminated;
36  int occupied;
38 
39 
40 typedef void(*event_function)(scheduler_t*, void*);
41 
45 typedef struct
46 {
47  void* first;
48  int second;
49 } arg_int;
50 
51 /* ************************************************************************** */
52 /* **** Constructor Destructor ********************************************** */
53 /* ************************************************************************** */
54 
55 event_t* event_init(void(*func)(scheduler_t*, void*), void* arg, char* name, char* source_name, uint16_t source_line);
56 void event_destroy(event_t* e);
59 
60 void event_loop_destroy();
61 
62 /* ************************************************************************** */
63 /* **** EventLoop Functions ************************************************* */
64 /* ************************************************************************** */
65 
66 #define event_signal(func, args) event_signal_ext(func, args, #func, __FILE__, __LINE__)
67 
68 void event_signal_ext(void* func, void* args, char* name, char* s_name, uint16_t s_line);
69 int event_loop_enter(scheduler_t* scheduler, void(*)(scheduler_t*), void(*)(scheduler_t*));
71 
72 #endif /* EVENT_H_INCLUDE */
int event_loop_put(event_loop_t *event_loop, event_t *event)
Definition: event.c:75
int event_loop_enter(scheduler_t *scheduler, void(*)(scheduler_t *), void(*)(scheduler_t *))
Enters the event loop.
Definition: event.c:221
void event_destroy(event_t *e)
Free any memory associated with an event.
Definition: event.c:165
void event_loop_terminate()
Stops the event loop from executing.
Definition: event.c:275
void event_signal_ext(void *func, void *args, char *name, char *s_name, uint16_t s_line)
Definition: event.c:200
event_t * event_loop_take(event_loop_t *event_loop)
Definition: event.c:90
event_t * event_init(void(*func)(scheduler_t *, void *), void *arg, char *name, char *source_name, uint16_t source_line)
Definition: event.c:147
void event_loop_destroy()
Frees any memory associated with the event queue.
Definition: event.c:179
struct event_loop event_loop_t
Header file for the scheduler.
Definition: event.h:46
GAsyncQueue * queue
The queue that is the core of the event loop.
Definition: event.h:34
int terminated
Flag that signals the end of the event loop.
Definition: event.h:35
int occupied
Does this loop already have a worker thread.
Definition: event.h:36
Definition: event.h:24
char * name
Name of the event, used for debugging.
Definition: event.h:27
char * source_name
Name of the source file creating the event.
Definition: event.h:28
void * argument
The arguments for the function.
Definition: event.h:26
uint16_t source_line
Line in the source file creating the event.
Definition: event.h:29
char * s_name
Sample source file name.
Definition: testEvent.c:27
uint16_t s_line
Sample source line number.
Definition: testEvent.c:28