possible fix for the scheduler bug

This commit is contained in:
fgerlits 2006-12-01 17:49:48 +00:00
parent e306a94e54
commit 93dbbeaa6d
2 changed files with 16 additions and 5 deletions

View File

@ -62,12 +62,12 @@ SchedulerThread :: SchedulerThread(
Ptr<EventContainerInterface>::Ref eventContainer, Ptr<EventContainerInterface>::Ref eventContainer,
Ptr<time_duration>::Ref granularity) Ptr<time_duration>::Ref granularity)
throw () throw ()
: eventContainer(eventContainer),
granularity(granularity),
shouldRun(false),
isPreloading(false)
{ {
//DEBUG_FUNC_INFO //DEBUG_FUNC_INFO
this->eventContainer = eventContainer;
this->granularity = granularity;
this->shouldRun = false;
} }
@ -113,6 +113,7 @@ SchedulerThread :: nextStep(Ptr<ptime>::Ref now) throw ()
std::cerr << "event initialization error: " << e.what() std::cerr << "event initialization error: " << e.what()
<< std::endl; << std::endl;
} }
isPreloading = true;
} else if (imminent(now, nextEventTime)) { } else if (imminent(now, nextEventTime)) {
Ptr<time_duration>::Ref timeLeft(new time_duration(*nextEventTime Ptr<time_duration>::Ref timeLeft(new time_duration(*nextEventTime
- *now)); - *now));
@ -122,6 +123,7 @@ SchedulerThread :: nextStep(Ptr<ptime>::Ref now) throw ()
currentEvent = nextEvent; currentEvent = nextEvent;
currentEventEnd = nextEventEnd; currentEventEnd = nextEventEnd;
getNextEvent(TimeConversion::now()); getNextEvent(TimeConversion::now());
isPreloading = false;
} }
} }
@ -132,6 +134,7 @@ SchedulerThread :: nextStep(Ptr<ptime>::Ref now) throw ()
currentEvent->stop(); currentEvent->stop();
currentEvent->deInitialize(); currentEvent->deInitialize();
currentEvent.reset(); currentEvent.reset();
isPreloading = false;
debug() << "::nextStep() - End [" << *TimeConversion::now() << "]" << endl; debug() << "::nextStep() - End [" << *TimeConversion::now() << "]" << endl;
} }
} }
@ -176,7 +179,9 @@ SchedulerThread :: signal(int signalId) throw ()
switch (signalId) { switch (signalId) {
case UpdateSignal: case UpdateSignal:
getNextEvent(TimeConversion::now()); if (!isPreloading) {
getNextEvent(TimeConversion::now());
}
break; break;
default: default:

View File

@ -127,6 +127,12 @@ class SchedulerThread : public virtual RunnableInterface
*/ */
bool shouldRun; bool shouldRun;
/**
* Flag indicating that we are between an initialize() and
* a start() call.
*/
bool isPreloading;
/** /**
* Default constructor. * Default constructor.
*/ */