[Scummvm-cvs-logs] scummvm master -> 269ea2f6be551f3159c1e508e28ebd2a609f5ab0
dreammaster
dreammaster at scummvm.org
Sun Jun 17 09:30:21 CEST 2012
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
269ea2f6be COMMON: Change pulseEvent to better reflect how it works in Windows
Commit: 269ea2f6be551f3159c1e508e28ebd2a609f5ab0
https://github.com/scummvm/scummvm/commit/269ea2f6be551f3159c1e508e28ebd2a609f5ab0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-06-17T00:29:20-07:00
Commit Message:
COMMON: Change pulseEvent to better reflect how it works in Windows
Changed paths:
common/coroutines.cpp
common/coroutines.h
diff --git a/common/coroutines.cpp b/common/coroutines.cpp
index 241d31e..042b15b 100644
--- a/common/coroutines.cpp
+++ b/common/coroutines.cpp
@@ -245,6 +245,15 @@ void CoroutineScheduler::schedule() {
pProc = pNext;
}
+
+ // Disable any events that were pulsed
+ Common::List<EVENT *>::iterator i;
+ for (i = _events.begin(); i != _events.end(); ++i) {
+ EVENT *evt = *i;
+ if (evt->pulsing) {
+ evt->pulsing = evt->signalled = false;
+ }
+ }
}
void CoroutineScheduler::rescheduleAll() {
@@ -678,6 +687,7 @@ uint32 CoroutineScheduler::createEvent(bool bManualReset, bool bInitialState) {
evt->pid = ++pidCounter;
evt->manualReset = bManualReset;
evt->signalled = bInitialState;
+ evt->pulsing = false;
_events.push_back(evt);
return evt->pid;
@@ -707,49 +717,15 @@ void CoroutineScheduler::pulseEvent(uint32 pidEvent) {
EVENT *evt = getEvent(pidEvent);
if (!evt)
return;
-
- // Set the event as true
+
+ // Set the event as signalled and pulsing
evt->signalled = true;
+ evt->pulsing = true;
- // start dispatching active process list for any processes that are currently waiting
- PROCESS *pOriginal = pCurrent;
- PROCESS *pNext;
- PROCESS *pProc = active->pNext;
- while (pProc != NULL) {
- pNext = pProc->pNext;
-
- // Only call processes that are currently waiting (either in waitForSingleObject or
- // waitForMultipleObjects) for the given event Pid
- for (int i = 0; i < CORO_MAX_PID_WAITING; ++i) {
- if (pProc->pidWaiting[i] == pidEvent) {
- // Dispatch the process
- pCurrent = pProc;
- pProc->coroAddr(pProc->state, pProc->param);
-
- if (!pProc->state || pProc->state->_sleep <= 0) {
- // Coroutine finished
- pCurrent = pCurrent->pPrevious;
- killProcess(pProc);
- } else {
- pProc->sleepTime = pProc->state->_sleep;
- }
-
- // pCurrent may have been changed
- pNext = pCurrent->pNext;
- pCurrent = NULL;
-
- break;
- }
- }
-
- pProc = pNext;
- }
-
- // Restore the original current process (if one was active)
- pCurrent = pOriginal;
-
- // Reset the event back to non-signalled
- evt->signalled = false;
+ // If there's an active process, and it's not the first in the queue, then reschedule all
+ // the other prcoesses in the queue to run again this frame
+ if (pCurrent && pCurrent != active->pNext)
+ rescheduleAll();
}
} // end of namespace Common
diff --git a/common/coroutines.h b/common/coroutines.h
index 64eabbf..834c67f 100644
--- a/common/coroutines.h
+++ b/common/coroutines.h
@@ -316,6 +316,7 @@ struct EVENT {
uint32 pid;
bool manualReset;
bool signalled;
+ bool pulsing;
};
More information about the Scummvm-git-logs
mailing list