#include <coroutines.h>
Public Types | |
| typedef void(* | VFPTRPP) (PROCESS *) |
Public Member Functions | |
| void | reset () |
| void | schedule () |
| void | rescheduleAll () |
| void | reschedule (PPROCESS pReSchedProc=nullptr) |
| void | giveWay (PPROCESS pReSchedProc=nullptr) |
| void | waitForSingleObject (Common::CoroContext &coroParam, int pid, uint32 duration, bool *expired=nullptr) |
| void | waitForMultipleObjects (Common::CoroContext &coroParam, int nCount, uint32 *pidList, bool bWaitAll, uint32 duration, bool *expired=nullptr) |
| void | sleep (Common::CoroContext &coroParam, uint32 duration) |
| 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) |
| void | killProcess (PROCESS *pKillProc) |
| PROCESS * | getCurrentProcess () |
| int | getCurrentPID () const |
| int | killMatchingProcess (uint32 pidKill, int pidMask=-1) |
| void | setResourceCallback (VFPTRPP pFunc) |
Event methods | |
| uint32 | createEvent (bool bManualReset, bool bInitialState) |
| void | closeEvent (uint32 pidEvent) |
| void | setEvent (uint32 pidEvent) |
| void | resetEvent (uint32 pidEvent) |
| void | pulseEvent (uint32 pidEvent) |
Additional Inherited Members | |
Static Public Member Functions inherited from Common::Singleton< CoroutineScheduler > | |
| static bool | hasInstance () |
| static CoroutineScheduler & | instance () |
| static void | destroy () |
Protected Types inherited from Common::Singleton< CoroutineScheduler > | |
| typedef CoroutineScheduler | SingletonBaseType |
Static Protected Attributes inherited from Common::Singleton< CoroutineScheduler > | |
| static CoroutineScheduler * | _singleton |
Create and manage "processes" (really coroutines).
| typedef void(* Common::CoroutineScheduler::VFPTRPP) (PROCESS *) |
Pointer to a function of the form "void function(PPROCESS)"
| void Common::CoroutineScheduler::reset | ( | ) |
Kill all processes and place them on the free list.
| void Common::CoroutineScheduler::schedule | ( | ) |
Give all active processes a chance to run.
| void Common::CoroutineScheduler::rescheduleAll | ( | ) |
Reschedule all processes to run again this tick.
| void Common::CoroutineScheduler::reschedule | ( | PPROCESS | pReSchedProc = nullptr | ) |
If the specified process has already run on this tick, make it run again on the current tick.
| void Common::CoroutineScheduler::giveWay | ( | PPROCESS | pReSchedProc = nullptr | ) |
Move the specified process to the end of the dispatch queue allowing it to run again within the current game cycle.
| pReSchedProc | The process to move. |
| void Common::CoroutineScheduler::waitForSingleObject | ( | Common::CoroContext & | coroParam, |
| int | pid, | ||
| uint32 | duration, | ||
| bool * | expired = nullptr |
||
| ) |
Continuously make a given process wait for another process to finish or event to signal.
| pid | Process/Event identifier. |
| duration | Duration in milliseconds. |
| expired | If specified, set to true if the delay period expired. |
| void Common::CoroutineScheduler::waitForMultipleObjects | ( | Common::CoroContext & | coroParam, |
| int | nCount, | ||
| uint32 * | pidList, | ||
| bool | bWaitAll, | ||
| uint32 | duration, | ||
| bool * | expired = nullptr |
||
| ) |
Continuously make a given process wait for given processes to finish or events to be set.
| nCount | Number of IDs being passed. |
| pidList | List of process IDs to wait for. |
| bWaitAll | Whether to wait for all or any of the processes/events. |
| duration | Duration in milliseconds. |
| expired | Set to true if the delay period expired. |
| void Common::CoroutineScheduler::sleep | ( | Common::CoroContext & | coroParam, |
| uint32 | duration | ||
| ) |
Make the active process sleep for the given duration in milliseconds.
| duration | Duration in milliseconds |
| PROCESS* Common::CoroutineScheduler::createProcess | ( | uint32 | pid, |
| CORO_ADDR | coroAddr, | ||
| const void * | pParam, | ||
| int | sizeParam | ||
| ) |
Create a new process.
| pid | Process identifier. |
| coroAddr | Coroutine start address. |
| pParam | Process-specific information. |
| sizeParam | Size of the process-specific information. |
| uint32 Common::CoroutineScheduler::createProcess | ( | CORO_ADDR | coroAddr, |
| const void * | pParam, | ||
| int | sizeParam | ||
| ) |
Create a new process with an auto-incrementing Process ID.
| coroAddr | Coroutine start address. |
| pParam | Process-specific information. |
| sizeParam | Size of process-specific information. |
| uint32 Common::CoroutineScheduler::createProcess | ( | CORO_ADDR | coroAddr, |
| const void * | pParam | ||
| ) |
Create a new process with an auto-incrementing Process ID and a single pointer parameter.
| coroAddr | Coroutine start address. |
| pParam | Process-specific information. |
| void Common::CoroutineScheduler::killProcess | ( | PROCESS * | pKillProc | ) |
Kill the specified process.
| pKillProc | The process to kill. |
| PROCESS* Common::CoroutineScheduler::getCurrentProcess | ( | ) |
Return a pointer to the currently running process.
| int Common::CoroutineScheduler::getCurrentPID | ( | ) | const |
Return the process identifier of the currently running process.
| int Common::CoroutineScheduler::killMatchingProcess | ( | uint32 | pidKill, |
| int | pidMask = -1 |
||
| ) |
Kill any process matching the specified PID. The current process cannot be killed.
| pidKill | Process identifier of the process to kill. |
| pidMask | Mask to apply to process identifiers before comparison. |
| void Common::CoroutineScheduler::setResourceCallback | ( | VFPTRPP | pFunc | ) |
Set pointer to a function to be called by killProcess().
May be called by a resource allocator. The function supplied is called by killProcess() to allow the resource allocator to free resources allocated to the dying process.
| pFunc | Function to be called by killProcess(). |
| uint32 Common::CoroutineScheduler::createEvent | ( | bool | bManualReset, |
| bool | bInitialState | ||
| ) |
Create a new event (semaphore) object.
| bManualReset | Events needs to be manually reset. Otherwise, events will be automatically reset after a process waits for the event to finish. |
| bInitialState | Specifies whether the event is signalled or not initially. |
| void Common::CoroutineScheduler::closeEvent | ( | uint32 | pidEvent | ) |
Destroy the given event.
| pidEvent | Event Process ID. |
| void Common::CoroutineScheduler::setEvent | ( | uint32 | pidEvent | ) |
Set the event.
| pidEvent | Event Process ID. |
| void Common::CoroutineScheduler::resetEvent | ( | uint32 | pidEvent | ) |
Reset the event.
| pidEvent | Event Process ID. |
| void Common::CoroutineScheduler::pulseEvent | ( | uint32 | pidEvent | ) |
Temporarily set a given event to true, and then run all waiting processes, allowing any processes waiting on the event to be fired. It then immediately resets the event again.
| pidEvent | Event Process ID. |