From a2b51174aad31f66280da91e9c7ec25babd045e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 25 May 2012 23:36:18 +1000 Subject: COMMON: Cleaned up coroutine comments --- common/coroutines.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common/coroutines.h') diff --git a/common/coroutines.h b/common/coroutines.h index 6df843887c..06af245ba7 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 */ -- cgit v1.2.3 From 415831987d542e249ef9032fdab49bece24934fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 29 May 2012 21:51:10 +1000 Subject: COMMON: Copied coroutine doxygen method descriptions to the header file --- common/coroutines.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'common/coroutines.h') diff --git a/common/coroutines.h b/common/coroutines.h index 06af245ba7..5daec4b426 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); }; -- cgit v1.2.3 From 29ebb2823dfe5fff95c47a2847f11e11bde95fd1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 31 May 2012 08:06:59 +1000 Subject: COMMON: Fix comment typo in coroutine comments --- common/coroutines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/coroutines.h') diff --git a/common/coroutines.h b/common/coroutines.h index 5daec4b426..abc114e0cf 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. */ -- cgit v1.2.3