PPI: Fix bad EventManager::eventTime() values before launching the scheduler
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1159
270642c3-0616-0410-b53a-bc976706d245
prefix_ senf::ClockService::clock_type senf::ppi::EventManager::now()
{
- return scheduler::eventTime();
+ return scheduler::now();
}
prefix_ senf::ClockService::clock_type senf::ppi::EventManager::time()
return eventTime_;
}
+
///////////////////////////////////////////////////////////////////////////
// senf::scheduler::detail::FdManager::Event
/**< This call waits until at least one event is posted but
no longer than the current timeout(). */
ClockService::clock_type eventTime() const; ///< Time of last event
-
+
protected:
private:
namespace {
bool terminate_ (false);
+ bool running_ (false);
}
prefix_ void senf::scheduler::terminate()
terminate_ = true;
}
+prefix_ bool senf::scheduler::running()
+{
+ return running_;
+}
+
+prefix_ senf::ClockService::clock_type senf::scheduler::now()
+{
+ return running() ? eventTime() : ClockService::now();
+}
+
namespace {
// We don't want try { } catch(...) { ... throw; } since that will make debugging more
senf::scheduler::detail::FIFORunner::instance().startWatchdog();
senf::scheduler::detail::SignalDispatcher::instance().unblockSignals();
senf::scheduler::detail::TimerDispatcher::instance().enable();
+ running_ = true;
}
~SchedulerScopedInit()
senf::scheduler::detail::TimerDispatcher::instance().disable();
senf::scheduler::detail::SignalDispatcher::instance().blockSignals();
senf::scheduler::detail::FIFORunner::instance().stopWatchdog();
+ running_ = false;
}
};
}
{
SchedulerScopedInit initScheduler;
terminate_ = false;
+ running_ = true;
detail::TimerDispatcher::instance().reschedule();
while(! terminate_ && ! (detail::FdDispatcher::instance().empty() &&
detail::TimerDispatcher::instance().empty() &&
\li a callback calls terminate()
\li the run queue becomes empty.
*/
- void process();
+ void process();
+
+ /** \brief \c true, if scheduler is running, \c false otherwise */
+ bool running();
/** \brief Called by callbacks to terminate the main loop
*/
ClockService::clock_type eventTime();
+ /** \brief Return (approximate) current time
+
+ This call will return the current time as far as it is already known to the scheduler. If
+ the scheduler is running, this will return eventTime(), otherwise it will return
+ ClockService::now(). While the scheduler is running, this will reduce the number of system
+ calls.
+ */
+ ClockService::clock_type now();
+
/** \brief Set watchdog timeout to \a ms milliseconds.
Setting the watchdog timeout to 0 will disable the watchdog.