Beispiel #1
0
int GUI::run(int startCode) {
	_startCode  = startCode;
	_returnCode = 0;

	EventMan.flushEvents();

	removeFocus();
	updateMouse();

	// Run as long as we don't have a return code
	while (_returnCode == 0) {
		// Call the periodic run callback
		callbackRun();
		if (_returnCode != 0)
			break;

		// But return immediately when an engine quit was requested
		if (EventMan.quitRequested())
			return 0;

		// Handle events
		Events::Event event;
		while (EventMan.pollEvent(event))
			addEvent(event);

		processEventQueue();

		// Delay for a while
		if (!EventMan.quitRequested() && (_returnCode != 0))
			EventMan.delay(10);
	}

	return _returnCode;
}
Beispiel #2
0
bool Server::loop() {
    if (_listenSock == -1) {
        LS_ERROR(_logger, "Server not initialised");
        return false;
    }

    // Stash away "the" server thread id.
    _threadId = gettid();

    while (!_terminate) {
        // Always process events first to catch start up events.
        processEventQueue();
        checkAndDispatchEpoll(EpollTimeoutMillis);
    }
    // Reasonable effort to ensure anything enqueued during terminate has a chance to run.
    processEventQueue();
    LS_INFO(_logger, "Server terminating");
    shutdown();
    return _expectedTerminate;
}
Beispiel #3
0
Server::PollResult Server::poll(int millis) {
    // Grab the thread ID on the first poll.
    if (_threadId == 0) _threadId = gettid();
    if (_threadId != gettid()) {
        LS_ERROR(_logger, "poll() called from the wrong thread");
        return PollResult::Error;
    }
    if (_listenSock == -1) {
        LS_ERROR(_logger, "Server not initialised");
        return PollResult::Error;
    }
    processEventQueue();
    checkAndDispatchEpoll(millis);
    if (!_terminate) return PollResult::Continue;

    // Reasonable effort to ensure anything enqueued during terminate has a chance to run.
    processEventQueue();
    LS_INFO(_logger, "Server terminating");
    shutdown();

    return _expectedTerminate ? PollResult::Terminated : PollResult::Error;
}
Beispiel #4
0
/**
 * Traitement du module d'evenements
 */
void EventsEngine::frame()
{
    log("Debut de la gestion des evenements");

    while(core->getIsRunning()) {
        // Attend que la file d'event ou de message ne soit plus vide
        boost::mutex::scoped_lock lockQueue(mutexQueue);
        while(event_queue.empty() && message_queue.empty())
            condQueue.wait(lockQueue);
        lockQueue.unlock();

        // Traitement des messages
        processQueue();

        // Traitement des events
        processEventQueue();
    }
}
 void ScriptObject::onUpdate(const float delta) {
   invokeScriptFunction(std::bind(script_on_update, script_object, delta));
   processEventQueue();
 }