\brief TimerEventProxy non-inline template implementation */
// Custom includes
+#include <senf/Utils/membind.hh>
#define prefix_
-///////////////////////////////ct.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
template<typename IdType>
prefix_ senf::scheduler::TimerEventProxy<IdType>::TimerEventProxy(std::string const & description)
template<typename IdType>
prefix_ void senf::scheduler::TimerEventProxy<IdType>::timerEvent()
{
- ClockService::clock_type now = ClockService::now();
+ ClockService::clock_type now = senf::scheduler::now();
typename EntrySetByTimeout_t::iterator it = entrySetByTimeout.begin();
while (it != entrySetByTimeout.end() && it->timeout <= now) {
Entry item (*it);
prefix_ void senf::scheduler::TimerEventProxy<IdType>::add(
ClockService::clock_type timeout, IdType const & id, Callback cb)
{
- // insert new entry
- entrySetByTimeout.insert( Entry(timeout, id, cb));
+ // insert new entry or replace the timeout of an entry already indexed
+ typename EntrySetById_t::iterator i = entrySetById.find(id);
+ if(i == entrySetById.end())
+ entrySetByTimeout.insert( Entry(timeout, id, cb));
+ else{
+ Entry tmp = *i;
+ tmp.timeout = timeout;
+ entrySetById.replace(i,tmp);
+ }
// the scheduler time to the first earliest timeout (ordered index)
timer.timeout( entrySetByTimeout.begin()->timeout);
}
return tmp;
}
-///////////////////////////////ct.e////////////////////////////////////////
+template<typename IdType>
+prefix_ unsigned senf::scheduler::TimerEventProxy<IdType>::numEvents()
+ const
+{
+ return entrySetByTimeout.size();
+}
+
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
#undef prefix_
\f