xennygrimmato
xennygrimmato

Reputation: 2796

How does event_base_dispatch( ) work?

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?

Upvotes: 2

Views: 6489

Answers (1)

1000ml
1000ml

Reputation: 884

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

Upvotes: 4

Related Questions