How does event_base_dispatch( ) work?

6k views Asked by At

What happens internally when event_base_dispatch( ) function is called? Are there any threads that are created which keep running until some signal to stop is received?

1

There are 1 answers

0
1000ml On

event_base_dispatch() is a blocking call which executes your defined callbacks inside a loop in the thread that calls the function. It continues to run until there are no more registered events or you call event_base_loopexit() / event_base_loopbreak().
See http://www.wangafu.net/~nickm/libevent-book/Ref3_eventloop.html

It is equivalent to event_base_loop(event_base, 0). After taking a quick look at the source code, I don't see any other threads created:
https://github.com/libevent/libevent/blob/master/event.c#L1847