Suppose I have one event_base that is event_loop'd 3 times. This easiely happens with GUIs and modal dialogs.
This means I have 1 main-eventloop and 2 modal-eventloops.
The callstack looks like:
event_loop() // 3
event_loop() // 2
event_loop() // 1
At some point in the future the exit condition for the inner loop (3) is reached and event_loopexit is called. This leaves the innermost mainloop (3). So far so good.
But under special conditions in my program the exit condition for the middle event_loop (2) is reached before that for (3). Now calling event_loopexit does leave loop (3) and stays in (2) forever.
Note that I don't want to exit loop (3) when only the exit condition for loop (2) is reached. But as soon as the exit condition for loop (3) is reached, both mainloops should return immediately.
This means that signaling the exit condition with event_loopexit doesn't work for me. I need something like this:
bool doexit = false;
event_loop( 0, &doexit )
doexit = true;
So every mainloop instance gets its own exit variable.
There is no need to add a special event to signal the loop exit because as soon as the current event handler returns the event_loop will be break'ed