[Scummvm-cvs-logs] scummvm master -> b8989cafc725a262d6f3c941c44f2e1a54d6818d
dreammaster
dreammaster at scummvm.org
Mon Jun 4 14:00:15 CEST 2012
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4719fd9900 COMMON: Fix comparison operation on coroutine wait methods
839527a955 COMMON: Fix method error messages
a2b51174aa COMMON: Cleaned up coroutine comments
5ba886ce8b COMMON: Fixed CORO_ADDR parameter names in Doxygen comments
415831987d COMMON: Copied coroutine doxygen method descriptions to the header file
29ebb2823d COMMON: Fix comment typo in coroutine comments
b8989cafc7 COMMON: Merge of pull request #240, coroutine code cleanup
Commit: 4719fd99007df8b4e20b93484a2229e32aed6261
https://github.com/scummvm/scummvm/commit/4719fd99007df8b4e20b93484a2229e32aed6261
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-05-25T06:06:24-07:00
Commit Message:
COMMON: Fix comparison operation on coroutine wait methods
Changed paths:
common/coroutines.cpp
diff --git a/common/coroutines.cpp b/common/coroutines.cpp
index d511ab4..4a45f2e 100644
--- a/common/coroutines.cpp
+++ b/common/coroutines.cpp
@@ -386,7 +386,7 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio
*expired = true;
// Outer loop for doing checks until expiry
- while (g_system->getMillis() < _ctx->endTime) {
+ while (g_system->getMillis() <= _ctx->endTime) {
// Check to see if a process or event with the given Id exists
_ctx->pProcess = getProcess(pid);
_ctx->pEvent = !_ctx->pProcess ? getEvent(pid) : NULL;
@@ -456,7 +456,7 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *
*expired = true;
// Outer loop for doing checks until expiry
- while (g_system->getMillis() < _ctx->endTime) {
+ while (g_system->getMillis() <= _ctx->endTime) {
_ctx->signalled = bWaitAll;
for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) {
Commit: 839527a9553e94234a1eb802648a4ed64e926a5c
https://github.com/scummvm/scummvm/commit/839527a9553e94234a1eb802648a4ed64e926a5c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-05-25T06:13:55-07:00
Commit Message:
COMMON: Fix method error messages
Changed paths:
common/coroutines.cpp
diff --git a/common/coroutines.cpp b/common/coroutines.cpp
index 4a45f2e..aff13a5 100644
--- a/common/coroutines.cpp
+++ b/common/coroutines.cpp
@@ -433,7 +433,7 @@ void CoroutineScheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duratio
void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll,
uint32 duration, bool *expired) {
if (!pCurrent)
- error("Called CoroutineScheduler::waitForMultipleEvents from the main process");
+ error("Called CoroutineScheduler::waitForMultipleObjects from the main process");
CORO_BEGIN_CONTEXT;
uint32 endTime;
@@ -505,7 +505,7 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *
*/
void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) {
if (!pCurrent)
- error("Called CoroutineScheduler::waitForSingleObject from the main process");
+ error("Called CoroutineScheduler::sleep from the main process");
CORO_BEGIN_CONTEXT;
uint32 endTime;
Commit: a2b51174aad31f66280da91e9c7ec25babd045e6
https://github.com/scummvm/scummvm/commit/a2b51174aad31f66280da91e9c7ec25babd045e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-05-25T06:36:18-07:00
Commit Message:
COMMON: Cleaned up coroutine comments
Changed paths:
common/coroutines.cpp
common/coroutines.h
diff --git a/common/coroutines.cpp b/common/coroutines.cpp
index aff13a5..b1b08c6 100644
--- a/common/coroutines.cpp
+++ b/common/coroutines.cpp
@@ -37,11 +37,15 @@ DECLARE_SINGLETON(CoroutineScheduler);
#ifdef COROUTINE_DEBUG
namespace {
+/** Count of active coroutines */
static int s_coroCount = 0;
typedef Common::HashMap<Common::String, int> CoroHashMap;
static CoroHashMap *s_coroFuncs = 0;
+/**
+ * Change the current coroutine status
+ */
static void changeCoroStats(const char *func, int change) {
if (!s_coroFuncs)
s_coroFuncs = new CoroHashMap();
@@ -49,6 +53,9 @@ static void changeCoroStats(const char *func, int change) {
(*s_coroFuncs)[func] += change;
}
+/**
+ * Display the details of active coroutines
+ */
static void displayCoroStats() {
debug("%d active coros", s_coroCount);
@@ -65,6 +72,9 @@ static void displayCoroStats() {
}
#endif
+/**
+ * Creates a coroutine context
+ */
CoroBaseContext::CoroBaseContext(const char *func)
: _line(0), _sleep(0), _subctx(0) {
#ifdef COROUTINE_DEBUG
@@ -74,6 +84,9 @@ CoroBaseContext::CoroBaseContext(const char *func)
#endif
}
+/**
+ * Destructor for coroutine context
+ */
CoroBaseContext::~CoroBaseContext() {
#ifdef COROUTINE_DEBUG
s_coroCount--;
@@ -499,7 +512,7 @@ void CoroutineScheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *
/**
* Make the active process sleep for the given duration in milliseconds
- * @param duration Duration in milliseconds
+ * @param duration Duration in milliseconds
* @remarks This duration won't be precise, since it relies on the frequency the
* scheduler is called.
*/
@@ -530,9 +543,9 @@ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) {
* Creates a new process.
*
* @param pid process identifier
- * @param CORO_ADDR coroutine start address
- * @param pParam process specific info
- * @param sizeParam size of process specific info
+ * @param CORO_ADDR Coroutine start address
+ * @param pParam Process specific info
+ * @param sizeParam Size of process specific info
*/
PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) {
PROCESS *pProc;
@@ -601,9 +614,9 @@ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const
/**
* Creates a new process with an auto-incrementing Process Id.
*
- * @param CORO_ADDR coroutine start address
- * @param pParam process specific info
- * @param sizeParam size of process specific info
+ * @param CORO_ADDR Coroutine start address
+ * @param pParam Process specific info
+ * @param sizeParam Size of process specific info
*/
uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) {
PROCESS *pProc = createProcess(++pidCounter, coroAddr, pParam, sizeParam);
@@ -613,9 +626,9 @@ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam,
/**
* Creates a new process with an auto-incrementing Process Id, and a single pointer parameter.
*
- * @param CORO_ADDR coroutine start address
- * @param pParam process specific info
- * @param sizeParam size of process specific info
+ * @param CORO_ADDR Coroutine start address
+ * @param pParam Process specific info
+ * @param sizeParam Size of process specific info
*/
uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam) {
return createProcess(coroAddr, &pParam, sizeof(void *));
@@ -625,7 +638,7 @@ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam)
/**
* Kills the specified process.
*
- * @param pKillProc which process to kill
+ * @param pKillProc Which process to kill
*/
void CoroutineScheduler::killProcess(PROCESS *pKillProc) {
// make sure a valid process pointer
@@ -674,7 +687,7 @@ PROCESS *CoroutineScheduler::getCurrentProcess() {
/**
* Returns the process identifier of the specified process.
*
- * @param pProc which process
+ * @param pProc Which process
*/
int CoroutineScheduler::getCurrentPID() const {
PROCESS *pProc = pCurrent;
@@ -690,9 +703,9 @@ int CoroutineScheduler::getCurrentPID() const {
* Kills any process matching the specified PID. The current
* process cannot be killed.
*
- * @param pidKill process identifier of process to kill
- * @param pidMask mask to apply to process identifiers before comparison
- * @return The number of processes killed is returned.
+ * @param pidKill Process identifier of process to kill
+ * @param pidMask Mask to apply to process identifiers before comparison
+ * @return The number of processes killed is returned.
*/
int CoroutineScheduler::killMatchingProcess(uint32 pidKill, int pidMask) {
int numKilled = 0;
@@ -750,7 +763,7 @@ int CoroutineScheduler::killMatchingProcess(uint32 pidKill, int pidMask) {
* called by killProcess() to allow the resource allocator to free
* resources allocated to the dying process.
*
- * @param pFunc Function to be called by killProcess()
+ * @param pFunc Function to be called by killProcess()
*/
void CoroutineScheduler::setResourceCallback(VFPTRPP pFunc) {
pRCfunction = pFunc;
@@ -778,9 +791,9 @@ EVENT *CoroutineScheduler::getEvent(uint32 pid) {
/**
* Creates a new event object
- * @param bManualReset Events needs to be manually reset. Otherwise, events
+ * @param bManualReset Events needs to be manually reset. Otherwise, events
* will be automatically reset after a process waits on the event finishes
- * @param bInitialState Specifies whether the event is signalled or not initially
+ * @param bInitialState Specifies whether the event is signalled or not initially
*/
uint32 CoroutineScheduler::createEvent(bool bManualReset, bool bInitialState) {
EVENT *evt = new EVENT();
@@ -794,7 +807,7 @@ uint32 CoroutineScheduler::createEvent(bool bManualReset, bool bInitialState) {
/**
* Destroys the given event
- * @param pidEvent Event PID
+ * @param pidEvent Event Process Id
*/
void CoroutineScheduler::closeEvent(uint32 pidEvent) {
EVENT *evt = getEvent(pidEvent);
@@ -806,7 +819,7 @@ void CoroutineScheduler::closeEvent(uint32 pidEvent) {
/**
* Sets the event
- * @param pidEvent Event PID
+ * @param pidEvent Event Process Id
*/
void CoroutineScheduler::setEvent(uint32 pidEvent) {
EVENT *evt = getEvent(pidEvent);
@@ -816,7 +829,7 @@ void CoroutineScheduler::setEvent(uint32 pidEvent) {
/**
* Resets the event
- * @param pidEvent Event PID
+ * @param pidEvent Event Process Id
*/
void CoroutineScheduler::resetEvent(uint32 pidEvent) {
EVENT *evt = getEvent(pidEvent);
@@ -827,7 +840,7 @@ void CoroutineScheduler::resetEvent(uint32 pidEvent) {
/**
* Temporarily sets a given event to true, and then runs all waiting processes, allowing any
* processes waiting on the event to be fired. It then immediately resets the event again.
- * @param pidEvent Event PID
+ * @param pidEvent Event Process Id
*
* @remarks Should not be run inside of another process
*/
@@ -880,5 +893,4 @@ void CoroutineScheduler::pulseEvent(uint32 pidEvent) {
evt->signalled = false;
}
-
} // end of namespace Common
diff --git a/common/coroutines.h b/common/coroutines.h
index 6df8438..06af245 100644
--- a/common/coroutines.h
+++ b/common/coroutines.h
@@ -65,7 +65,8 @@ typedef CoroBaseContext *CoroContext;
/** This is a special constant that can be temporarily used as a parameter to call coroutine-ised
* from methods from methods that haven't yet been converted to being a coroutine, so code at least
- * compiles correctly. Be aware, though, that if you use this, you will get runtime errors.
+ * compiles correctly. Be aware, though, that an error will occur if a coroutine that was passed
+ * the nullContext tries to sleep or yield control.
*/
extern CoroContext nullContext;
@@ -283,6 +284,7 @@ public:
#define CORO_INFINITE 0xffffffff
#define CORO_INVALID_PID_VALUE 0
+/** Coroutine parameter for methods converted to coroutines */
typedef void (*CORO_ADDR)(CoroContext &, const void *);
/** process structure */
Commit: 5ba886ce8b3dc5b543d81e3f3a655b328749d778
https://github.com/scummvm/scummvm/commit/5ba886ce8b3dc5b543d81e3f3a655b328749d778
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-05-29T04:43:23-07:00
Commit Message:
COMMON: Fixed CORO_ADDR parameter names in Doxygen comments
Changed paths:
common/coroutines.cpp
diff --git a/common/coroutines.cpp b/common/coroutines.cpp
index b1b08c6..6159bdc 100644
--- a/common/coroutines.cpp
+++ b/common/coroutines.cpp
@@ -542,8 +542,8 @@ void CoroutineScheduler::sleep(CORO_PARAM, uint32 duration) {
/**
* Creates a new process.
*
- * @param pid process identifier
- * @param CORO_ADDR Coroutine start address
+ * @param pid process identifier
+ * @param coroAddr Coroutine start address
* @param pParam Process specific info
* @param sizeParam Size of process specific info
*/
@@ -614,7 +614,7 @@ PROCESS *CoroutineScheduler::createProcess(uint32 pid, CORO_ADDR coroAddr, const
/**
* Creates a new process with an auto-incrementing Process Id.
*
- * @param CORO_ADDR Coroutine start address
+ * @param coroAddr Coroutine start address
* @param pParam Process specific info
* @param sizeParam Size of process specific info
*/
@@ -626,7 +626,7 @@ uint32 CoroutineScheduler::createProcess(CORO_ADDR coroAddr, const void *pParam,
/**
* Creates a new process with an auto-incrementing Process Id, and a single pointer parameter.
*
- * @param CORO_ADDR Coroutine start address
+ * @param coroAddr Coroutine start address
* @param pParam Process specific info
* @param sizeParam Size of process specific info
*/
Commit: 415831987d542e249ef9032fdab49bece24934fa
https://github.com/scummvm/scummvm/commit/415831987d542e249ef9032fdab49bece24934fa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-05-29T04:51:10-07:00
Commit Message:
COMMON: Copied coroutine doxygen method descriptions to the header file
Changed paths:
common/coroutines.h
diff --git a/common/coroutines.h b/common/coroutines.h
index 06af245..5daec4b 100644
--- a/common/coroutines.h
+++ b/common/coroutines.h
@@ -356,7 +356,6 @@ private:
PROCESS *getProcess(uint32 pid);
EVENT *getEvent(uint32 pid);
public:
-
CoroutineScheduler();
~CoroutineScheduler();
@@ -366,31 +365,62 @@ public:
void printStats();
#endif
+ /** Give all active processes a chance to run */
void schedule();
+
+ /** Reschedules all the processes to run again this tick */
void rescheduleAll();
+
+ /** If the specified process has already run on this tick, make it run again on the current tick. */
void reschedule(PPROCESS pReSchedProc = NULL);
+
+ /** Moves the specified process to the end of the dispatch queue, so it can again in the current tick */
void giveWay(PPROCESS pReSchedProc = NULL);
+
+ /** Continously makes a given process wait for another process to finish or event to signal. */
void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL);
+
+ /** Continously makes a given process wait for given prcesses to finished or events to be set */
void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll,
uint32 duration, bool *expired = NULL);
- void sleep(CORO_PARAM, uint32 duration);
+ /** Make the active process sleep for the given duration in milliseconds */
+ void sleep(CORO_PARAM, uint32 duration);
+
+ /** Creates a new process. */
PROCESS *createProcess(uint32 pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam);
uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam);
uint32 createProcess(CORO_ADDR coroAddr, const void *pParam);
+
+ /** Kills the specified process. */
void killProcess(PROCESS *pKillProc);
+ /** Returns a pointer to the currently running process. */
PROCESS *getCurrentProcess();
+
+ /** Returns the process identifier of the specified process. */
int getCurrentPID() const;
+
+ /** Kills any process matching the specified PID. The current process cannot be killed. */
int killMatchingProcess(uint32 pidKill, int pidMask = -1);
+ /** Set pointer to a function to be called by killProcess() */
void setResourceCallback(VFPTRPP pFunc);
/* Event methods */
+ /** Creates a new event (semaphore) object */
uint32 createEvent(bool bManualReset, bool bInitialState);
+
+ /** Destroys the given event */
void closeEvent(uint32 pidEvent);
+
+ /** Sets the event */
void setEvent(uint32 pidEvent);
+
+ /** Resets the event */
void resetEvent(uint32 pidEvent);
+
+ /** Temporarily sets a given event to true, allowing other waiting processes to fire */
void pulseEvent(uint32 pidEvent);
};
Commit: 29ebb2823dfe5fff95c47a2847f11e11bde95fd1
https://github.com/scummvm/scummvm/commit/29ebb2823dfe5fff95c47a2847f11e11bde95fd1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-05-30T15:06:59-07:00
Commit Message:
COMMON: Fix comment typo in coroutine comments
Changed paths:
common/coroutines.h
diff --git a/common/coroutines.h b/common/coroutines.h
index 5daec4b..abc114e 100644
--- a/common/coroutines.h
+++ b/common/coroutines.h
@@ -64,7 +64,7 @@ typedef CoroBaseContext *CoroContext;
/** This is a special constant that can be temporarily used as a parameter to call coroutine-ised
- * from methods from methods that haven't yet been converted to being a coroutine, so code at least
+ * methods from code that haven't yet been converted to being a coroutine, so code at least
* compiles correctly. Be aware, though, that an error will occur if a coroutine that was passed
* the nullContext tries to sleep or yield control.
*/
Commit: b8989cafc725a262d6f3c941c44f2e1a54d6818d
https://github.com/scummvm/scummvm/commit/b8989cafc725a262d6f3c941c44f2e1a54d6818d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2012-06-04T04:59:10-07:00
Commit Message:
COMMON: Merge of pull request #240, coroutine code cleanup
Changed paths:
common/coroutines.cpp
common/coroutines.h
More information about the Scummvm-git-logs
mailing list