blob: 158ca8688ee48760b518eedd94ca1a235e85c838 (
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
|
#include "fake-reactor.h"
#include <stdlib.h>
struct reactor {
struct fake_reactor_impl *impl;
};
struct reactor *reactor_create(void) {
return (struct reactor *)calloc(1, sizeof(struct reactor));
}
void reactor_destroy(struct reactor *reactor) { free(reactor); }
void reactor_update(struct reactor *reactor, int timeout_ms) {
(void)reactor;
(void)timeout_ms;
}
bool reactor_poll_event(struct reactor *reactor, uint32_t ev_id) {
if (reactor->impl != NULL) {
return reactor->impl->poll_event(reactor->impl->userdata, ev_id);
} else {
return false;
}
}
uint32_t reactor_register_interest(struct reactor *reactor, int fd,
enum interest interest) {
if (reactor->impl != NULL) {
return reactor->impl->register_interest(reactor->impl->userdata, fd,
interest);
} else {
return 0;
}
}
void reactor_unregister_interest(struct reactor *reactor, uint32_t ev_id) {
if (reactor->impl != NULL) {
reactor->impl->unregister_interest(reactor->impl->userdata, ev_id);
}
}
struct reactor *fake_reactor_create(struct fake_reactor_impl *impl) {
struct reactor *r = reactor_create();
set_reactor_impl(r, impl);
return r;
}
void set_reactor_impl(struct reactor *reactor, struct fake_reactor_impl *impl) {
reactor->impl = impl;
}
|