Exemplo n.º 1
0
int processTimeEvent(EventLoop * eventLoop_p){
    int processed = 0;
    TimeEvent * te;
    long long maxId;
    time_t now = time(NULL);

    
    te = eventLoop_p->timeEventHead;
    maxId = eventLoop_p->timeEventNextId-1;
    while(te) {
        long now_sec, now_ms;
        long long id;
        if (te->id > maxId)
            continue;
        getTime(&now_sec, &now_ms);
        if (te->trigger_sec < now_sec || (te->trigger_sec == now_sec && te->trigger_ms < now_ms)){
            int retval;
            id = te->id;
            retval = te->timeCallback(eventLoop_p, id, te->clientData);  
            processed ++;
            if (retval != EVENT_TIME_NOT_CYC){
                addMilsec2Now(retval, &te->trigger_sec, &te->trigger_ms) ;
            }else{
                delTimeEvent(eventLoop_p, id);     
            }
            //when process current time event , the timeEventHead could be changed
            //so change the te to  the first 

            te = eventLoop_p->timeEventHead; 
        }else{
            te = te->next;
        }
    }
    return processed;
}
Exemplo n.º 2
0
void AGOSEngine::killAllTimers() {
	TimeEvent *cur, *next;

	for (cur = _firstTimeStruct; cur; cur = next) {
		next = cur->next;
		delTimeEvent(cur);
	}
	_clickOnly = false;
}
Exemplo n.º 3
0
bool AGOSEngine::kickoffTimeEvents() {
	uint32 cur_time;
	TimeEvent *te;
	bool result = false;

	if (getGameType() == GType_FF && _clockStopped)
		return result;

	cur_time = getTime() - _gameStoppedClock;

	while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !shouldQuit()) {
		result = true;
		_pendingDeleteTimeEvent = te;
		invokeTimeEvent(te);
		if (_pendingDeleteTimeEvent) {
			_pendingDeleteTimeEvent = NULL;
			delTimeEvent(te);
		}
	}

	return result;
}