Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #225 from nolman/refactoring-runonce

Changed _Run*Once() to be void, always returned true.
  • Loading branch information...
commit 11ef5f97b6a094ac1c1c7d21ca638a88c8064fec 2 parents 933b388 + 0ad34cc
@tmm1 tmm1 authored
Showing with 14 additions and 44 deletions.
  1. +10 −40 ext/em.cpp
  2. +4 −4 ext/em.h
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);
@@ -539,7 +535,7 @@ bool EventMachine_t::_RunEpollOnce()
assert(errno != EINVAL);
assert(errno != EBADF);
}
- return true;
+ return;
}
TRAP_BEG;
@@ -577,8 +573,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
@@ -589,7 +583,7 @@ bool EventMachine_t::_RunEpollOnce()
EventMachine_t::_RunKqueueOnce
******************************/
-bool EventMachine_t::_RunKqueueOnce()
+void EventMachine_t::_RunKqueueOnce()
{
#ifdef HAVE_KQUEUE
assert (kqfd != -1);
@@ -618,7 +612,7 @@ bool EventMachine_t::_RunKqueueOnce()
assert(errno != EINVAL);
assert(errno != EBADF);
}
- return true;
+ return;
}
TRAP_BEG;
@@ -669,8 +663,6 @@ bool EventMachine_t::_RunKqueueOnce()
rb_thread_schedule();
}
#endif
-
- return true;
#else
throw std::runtime_error ("kqueue is not implemented on this platform");
#endif
@@ -843,37 +835,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;
@@ -975,8 +947,6 @@ bool EventMachine_t::_RunSelectOnce()
}
}
}
-
- return true;
}
void EventMachine_t::_CleanBadDescriptors()
View
8 ext/em.h
@@ -145,7 +145,7 @@ class EventMachine_t
uint64_t GetRealTime();
private:
- bool _RunOnce();
+ void _RunOnce();
void _RunTimers();
void _UpdateTime();
void _AddNewDescriptors();
@@ -153,9 +153,9 @@ class EventMachine_t
void _InitializeLoopBreaker();
void _CleanupSockets();
- bool _RunSelectOnce();
- bool _RunEpollOnce();
- bool _RunKqueueOnce();
+ void _RunSelectOnce();
+ void _RunEpollOnce();
+ void _RunKqueueOnce();
void _ModifyEpollEvent (EventableDescriptor*);
void _DispatchHeartbeats();
Please sign in to comment.
Something went wrong with that request. Please try again.