aboutsummaryrefslogtreecommitdiff
path: root/src/evloop.h
blob: f0d4f729558593ab88457a85842af6da31462c94 (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
#include "tsocket.h"

#ifndef __EVLOOP_H
#define __EVLOOP_H

#define EVENT_LOOP_MAX_EVENTS 1024

struct evloop;
typedef struct evloop evloop_t;

typedef void (*evloop_process_func_t)(void *data);
typedef void (*evloop_destroy_func_t)(void *data);

struct event {
    int fd;
    void *data;
    evloop_destroy_func_t destroy;
    evloop_process_func_t process;
};
typedef struct event event_t;

evloop_t *evloop_create();
int evloop_wait(evloop_t *el, int timeout);
int evloop_add(evloop_t *el, event_t *ev, int flag);
int evloop_remove(evloop_t *el, event_t *ev);
event_t *evloop_get(evloop_t *el, int index);
void evloop_loop(evloop_t *el);
event_t *event_create(void *data, int fd, 
        evloop_process_func_t process,
        evloop_destroy_func_t destroy);

#endif