Skip to content

Changed _Run*Once() to be void, always returned true. #225

Merged
merged 2 commits into from Feb 28, 2013
View
50 ext/em.cpp
@@ -482,8 +482,7 @@ void EventMachine_t::Run()
_AddNewDescriptors();
_ModifyDescriptors();
- if (!_RunOnce())
- break;
+ _RunOnce();
if (bTerminateSignalReceived)
break;
}
@@ -494,27 +493,24 @@ void EventMachine_t::Run()
EventMachine_t::_RunOnce
************************/
-bool EventMachine_t::_RunOnce()
+void EventMachine_t::_RunOnce()
{
- bool ret;
if (bEpoll)
- ret = _RunEpollOnce();
+ _RunEpollOnce();
else if (bKqueue)
- ret = _RunKqueueOnce();
+ _RunKqueueOnce();
else
- ret = _RunSelectOnce();
+ _RunSelectOnce();
_DispatchHeartbeats();
_CleanupSockets();
- return ret;
}
-
/*****************************
EventMachine_t::_RunEpollOnce
*****************************/
-bool EventMachine_t::_RunEpollOnce()
+void EventMachine_t::_RunEpollOnce()
{
#ifdef HAVE_EPOLL
assert (epfd != -1);
@@ -534,7 +530,7 @@ bool EventMachine_t::_RunEpollOnce()
assert(errno != EINVAL);
assert(errno != EBADF);
}
- return true;
+ return;
}
TRAP_BEG;
@@ -572,8 +568,6 @@ bool EventMachine_t::_RunEpollOnce()
timeval tv = {0, ((errno == EINTR) ? 5 : 50) * 1000};
EmSelect (0, NULL, NULL, NULL, &tv);
}
-
- return true;
#else
throw std::runtime_error ("epoll is not implemented on this platform");
#endif
@@ -584,7 +578,7 @@ bool EventMachine_t::_RunEpollOnce()
EventMachine_t::_RunKqueueOnce
******************************/
-bool EventMachine_t::_RunKqueueOnce()
+void EventMachine_t::_RunKqueueOnce()
{
#ifdef HAVE_KQUEUE
assert (kqfd != -1);
@@ -608,7 +602,7 @@ bool EventMachine_t::_RunKqueueOnce()
assert(errno != EINVAL);
assert(errno != EBADF);
}
- return true;
+ return;
}
TRAP_BEG;
@@ -659,8 +653,6 @@ bool EventMachine_t::_RunKqueueOnce()
rb_thread_schedule();
}
#endif
-
- return true;
#else
throw std::runtime_error ("kqueue is not implemented on this platform");
#endif
@@ -827,37 +819,17 @@ int SelectData_t::_Select()
EventMachine_t::_RunSelectOnce
******************************/
-bool EventMachine_t::_RunSelectOnce()
+void EventMachine_t::_RunSelectOnce()
{
// Crank the event machine once.
// If there are no descriptors to process, then sleep
// for a few hundred mills to avoid busy-looping.
- // Return T/F to indicate whether we should continue.
// This is based on a select loop. Alternately provide epoll
// if we know we're running on a 2.6 kernel.
// epoll will be effective if we provide it as an alternative,
// however it has the same problem interoperating with Ruby
// threads that select does.
- //cerr << "X";
-
- /* This protection is now obsolete, because we will ALWAYS
- * have at least one descriptor (the loop-breaker) to read.
- */
- /*
- if (Descriptors.size() == 0) {
- #ifdef OS_UNIX
- timeval tv = {0, 200 * 1000};
- EmSelect (0, NULL, NULL, NULL, &tv);
- return true;
- #endif
- #ifdef OS_WIN32
- Sleep (200);
- return true;
- #endif
- }
- */
-
SelectData_t SelectData;
/*
fd_set fdreads, fdwrites;
@@ -959,8 +931,6 @@ bool EventMachine_t::_RunSelectOnce()
}
}
}
-
- return true;
}
void EventMachine_t::_CleanBadDescriptors()
View
8 ext/em.h
@@ -131,17 +131,17 @@ class EventMachine_t
uint64_t GetRealTime();
private:
- bool _RunOnce();
+ void _RunOnce();
void _RunTimers();
void _UpdateTime();
void _AddNewDescriptors();
void _ModifyDescriptors();
void _InitializeLoopBreaker();
void _CleanupSockets();
- bool _RunSelectOnce();
- bool _RunEpollOnce();
- bool _RunKqueueOnce();
+ void _RunSelectOnce();
+ void _RunEpollOnce();
+ void _RunKqueueOnce();
void _ModifyEpollEvent (EventableDescriptor*);
void _DispatchHeartbeats();
Something went wrong with that request. Please try again.