452dea9a17e937bff45830ac7748e6b09353f800
[trust_router.git] / tr / tr_event.c
1 #include <event2/event.h>
2 #include <event2/thread.h>
3
4 #include <tr.h>
5 #include <tid_internal.h>
6 #include <tr_debug.h>
7 #include <tr_event.h>
8
9 /* Allocate and set up the event base, return a pointer
10  * to the new event_base or NULL on failure.
11  * Enables thread-safe mode. */
12 struct event_base *tr_event_loop_init(void)
13 {
14   struct event_base *base=NULL;
15
16   evthread_use_pthreads(); /* enable pthreads support */
17   base=event_base_new();
18   return base;
19 }
20
21 /* run the loop, does not normally return */
22 int tr_event_loop_run(struct event_base *base)
23 {
24   return event_base_dispatch(base);
25 }