27 #if !defined(BUILD_FEATURE_DETECTORGRAPH_CONFIG_LITE) 28 for (TimeoutDispatchersContainer::iterator tZombieDataIt = mTimeoutDispatchers.begin();
29 tZombieDataIt != mTimeoutDispatchers.end();
32 delete *tZombieDataIt;
35 for (PeriodicPublishingSeriesContainer::iterator tZombieDataIt = mPeriodicSeries.begin();
36 tZombieDataIt != mPeriodicSeries.end();
39 delete tZombieDataIt->mpDispatcher;
47 mTimeoutDispatchers.push_back(NULL);
48 #if defined(BUILD_FEATURE_DETECTORGRAPH_CONFIG_INSTRUMENT_RESOURCE_USAGE) 49 DG_LOG(
"Reserved UniqueTimerHandle=%d\n", (
int)newHandle);
54 void TimeoutPublisherService::ScheduleTimeoutDispatcher(
55 DispatcherInterface* aDispatcher,
60 DG_ASSERT(0 <= aHandle && (
unsigned)aHandle < mTimeoutDispatchers.size());
61 unsigned dispatcherIdx = (unsigned)aHandle;
63 DG_ASSERT(mTimeoutDispatchers[dispatcherIdx] == NULL);
64 mTimeoutDispatchers[dispatcherIdx] = aDispatcher;
69 void TimeoutPublisherService::SchedulePeriodicPublishingDispatcher(
70 DispatcherInterface* aDispatcher,
73 mMetronomePeriodMsec = gcd(aPeriodInMilliseconds, mMetronomePeriodMsec);
74 mPeriodicSeries.push_back(
75 PeriodicPublishingSeries(aPeriodInMilliseconds, aDispatcher));
81 DG_ASSERT(0 <= aHandle && (
unsigned)aHandle < mTimeoutDispatchers.size());
82 unsigned dispatcherIdx = (unsigned)aHandle;
83 DispatcherInterface* tDispatcher = mTimeoutDispatchers[dispatcherIdx];
89 #if defined(BUILD_FEATURE_DETECTORGRAPH_CONFIG_LITE) 90 mTimeoutDispatchersAllocator.Delete(tDispatcher);
94 mTimeoutDispatchers[dispatcherIdx] = NULL;
101 DG_ASSERT(0 <= aHandle && (
unsigned)aHandle < mTimeoutDispatchers.size());
102 unsigned dispatcherIdx = (unsigned)aHandle;
103 DispatcherInterface* tDispatcher = mTimeoutDispatchers[dispatcherIdx];
106 tDispatcher->Dispatch(mrGraph);
107 #if defined(BUILD_FEATURE_DETECTORGRAPH_CONFIG_LITE) 108 mTimeoutDispatchersAllocator.Delete(tDispatcher);
112 mTimeoutDispatchers[dispatcherIdx] = NULL;
119 DG_ASSERT(0 <= aHandle && (
unsigned)aHandle < mTimeoutDispatchers.size());
120 unsigned dispatcherIdx = (unsigned)aHandle;
121 return (mTimeoutDispatchers[dispatcherIdx] == NULL);
126 if (mMetronomePeriodMsec > 0)
129 #if defined(BUILD_FEATURE_DETECTORGRAPH_CONFIG_INSTRUMENT_RESOURCE_USAGE) 130 DG_LOG(
"Started Metronome with period of %d milliseconds\n", mMetronomePeriodMsec);
137 for (PeriodicPublishingSeriesContainer::iterator it = mPeriodicSeries.begin();
138 it != mPeriodicSeries.end();
141 it->mMetronomeAccumulator += mMetronomePeriodMsec;
142 if (it->mMetronomeAccumulator >= it->mPublishingPeriodMsec)
144 it->mpDispatcher->Dispatch(mrGraph);
145 it->mMetronomeAccumulator = 0;
155 #if defined(DG_TIMEOFFSET_REMAINDER) 156 rhs = DG_TIMEOFFSET_REMAINDER(lhs, rhs);
bool HasTimeoutExpired(const TimeoutPublisherHandle aTimerHandle) const
Returns weather the timeout for a given handle has expired/fired already.
void CancelPublishOnTimeout(const TimeoutPublisherHandle aTimerHandle)
Cancels a timeout and deletes the stored TopicState.
virtual void Start(const TimeoutPublisherHandle)=0
Should start a timer for the given handle.
Implements a graph of Topics & Detectors with Input/Output APIs.
virtual ~TimeoutPublisherService()
Destructor.
TimeoutPublisherHandle GetUniqueTimerHandle()
Returns a unique id/handle for a new timer.
TimeoutPublisherService(Graph &graph)
Constructor that initializes the service connected to a graph.
virtual void SetTimeout(const TimeOffset aMillisecondsFromNow, const TimeoutPublisherHandle)=0
Should setup a timeout for the given handle.
void DG_LOG(const char *aLogString,...)
virtual void StartMetronome(const TimeOffset aPeriodInMilliseconds)=0
Should start the metronome (periodic timer) for the given period.
int TimeoutPublisherHandle
void StartPeriodicPublishing()
Starts a Metronome to publish scheduled TopicStates.
void TimeoutExpired(const TimeoutPublisherHandle aTimerHandle)
Fires/Dispatches a TopicState that was pending on a timeout.
void MetronomeFired()
Update metronome counters and Fires/Dispatches TopicStates that was pending on scheduled period...
virtual void Cancel(const TimeoutPublisherHandle)=0
Should cancel the timer the given handle.
#define DG_ASSERT(condition)