-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.h
64 lines (53 loc) · 1.26 KB
/
event.h
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
/*
* event.h
*
* Created on: Oct 22, 2022
* Author: bhat
*/
#ifndef SRC_EVENT_H_
#define SRC_EVENT_H_
#define SIGNAL_MAX_SLOT_COUNT 4
#include "io/buf.h"
#include <stdbool.h>
#include "xil_types.h"
#define SLOT_TYPE void (*)(void*, void*)
#define SLOT_VAR(var_name) void (* ## var_name ## )(void*, void*)
struct EventLoop;
bool event_loop_empty(struct EventLoop* self);
void event_loop_push(
struct EventLoop* self,
SLOT_TYPE, void* data_ptr, void* aux_ptr
);
void event_loop_execute_one(struct EventLoop* self);
struct Signal;
void signal_initialize(
struct Signal* self,
struct EventLoop* event_loop
);
void signal_connect(
struct Signal* self,
SLOT_TYPE, void* data_ptr
);
void signal_disconnect(
struct Signal* self,
SLOT_TYPE
);
void signal_trigger(
struct Signal* self, struct EventLoop* event_loop,
void* aux_ptr
);
#define EVENT_LOOP_BUF_SIZE 128
struct EventLoop {
void (*buf[EVENT_LOOP_BUF_SIZE]) (void*, void*);
void* buf_data_ptrs[EVENT_LOOP_BUF_SIZE];
void* buf_aux_ptrs[EVENT_LOOP_BUF_SIZE];
struct BufAux buf_aux;
};
struct EventLoop event_loop_new();
struct Signal {
void (*slots[SIGNAL_MAX_SLOT_COUNT])(void*, void*);
void* slot_data_ptrs[SIGNAL_MAX_SLOT_COUNT];
u32 slot_count;
};
struct Signal signal_new();
#endif /* SRC_EVENT_H_ */