Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion fluid/base/EventLoop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ namespace fluid_base {
#define OF_MAX_LEN 0xFFFF

// See FIXME in EventLoop::EventLoop

#ifndef EVLOOP_NO_EXIT_ON_EMPTY
extern "C" void event_base_add_virtual(struct event_base *);
extern "C" void event_base_del_virtual(struct event_base *);
#endif


class EventLoop::LibEventEventLoop {
private:
Expand Down Expand Up @@ -41,7 +45,9 @@ EventLoop::EventLoop(int id) {
See:
http://stackoverflow.com/questions/7645217/user-triggered-event-in-libevent
*/
event_base_add_virtual(this->m_implementation->base);
#ifndef EVLOOP_NO_EXIT_ON_EMPTY
event_base_add_virtual(this->m_implementation->base);
#endif
}

EventLoop::~EventLoop() {
Expand All @@ -56,8 +62,13 @@ void EventLoop::run() {
event_base_dispatch(this->m_implementation->base);
// See note in EventLoop::EventLoop. Here we disable the virtual event
// to guarantee that nothing blocks.

#ifndef EVLOOP_NO_EXIT_ON_EMPTY
event_base_del_virtual(this->m_implementation->base);
event_base_loop(this->m_implementation->base, EVLOOP_NONBLOCK);
#else
event_base_loop(this->m_implementation->base, EVLOOP_NO_EXIT_ON_EMPTY);
#endif
}

void EventLoop::stop() {
Expand Down