示例#1
0
void scheduler () {
	uint i;
	while (1) {
		uint sleepAmount = nextSleep ();
		DEBUG (2, "We need to sleep for %u seconds\n", sleepAmount);
		sleep (sleepAmount);
		if (time (NULL) > appConf.endTime) {
			INFO ("End time reached. Terminating.\n");
			exit (0);
		}
		for (i=0; i<numResources; i++) {
			if (appConf.nextEventTime[i] != 0 && appConf.nextEventTime[i] <= time (NULL)) {
				updateNextEvent (i);
				incrementHog[i] (appConf.increment[i]);
			}
		}
		DEBUG (2, "Done\n");
	}
}
示例#2
0
文件: VTrack.cpp 项目: AnteSim/Verve
//-----------------------------------------------------------------------------
// 
// VTrack::onControllerUpdate( pTime, pDelta );
// 
// The Next Event is integrated until has finished its execution. Once it has
// finished, the next event to be triggered becomes the Current Event. Doing
// this means that only one event is ever checked to see if it should be
// triggered.
// 
//-----------------------------------------------------------------------------
void VTrack::onControllerUpdate( const S32 &pTime, const S32 &pDelta )
{
    if ( !isEnabled() || !mNextEvent )
    {
        // Don't Update.
        return;
    }

    // Update Next Event.
    while ( !mNextEvent->onControllerUpdate( pTime, pDelta ) )
    {
        // Next Event?
        if ( !updateNextEvent() )
        {
            // No Valid Events.
            mNextEvent = NULL;
            break;
        }
    }
}