|
| MicroScheduler () |
| Constructs a MicroScheduler in an uninitialized state. The user must call MicroScheduler::initialize to initialize the scheduler before use, otherwise calls to this MicroScheduler are undefined.
|
|
virtual | ~MicroScheduler () |
| Implicitly shuts down the MicroScheduler if it's still running.
|
|
| MicroScheduler (MicroScheduler const &)=delete |
|
MicroScheduler & | operator= (MicroScheduler const &)=delete |
|
bool | initialize (WorkerPool *pWorkerPool) |
| Initializes the MicroScheduler and attaches it to pWorkPool, where each worker in pWorkPool will execute submitted tasks. More...
|
|
bool | initialize (MicroSchedulerDesc const &desc) |
| Initializes the MicroScheduler for use. It creates the worker thread pool and allocates all memory to meet the requirements in desc. More...
|
|
void | shutdown () |
| Stops the MicroScheduler and destroys all resources. The TaskSchuduler is now in an unusable state. All subsequent calls to this MicroScheduler are undefined.
|
|
template<typename TTask , typename... TArgs> |
GTS_INLINE TTask * | allocateTask (TArgs &&... args) |
| Allocates a new Task object of type TTask. More...
|
|
template<typename TFunc , typename... TArgs> |
GTS_INLINE Task * | allocateTask (TFunc &&func, TArgs &&... args) |
| Allocates a new Task object and emplaces the function/lambda data. More...
|
|
void | spawnTask (Task *pTask, uint32_t priority=0) |
| Spawns the specified 'pTask' to be executed by the scheduler. Spawned tasks are executed in LIFO order, and stolen in FIFO order. More...
|
|
void | spawnTaskAndWait (Task *pTask, uint32_t priority=0) |
| Spawns the specified 'pTask' to be executed by the scheduler and then waits for its reference count to become one. More...
|
|
void | waitFor (Task *pTask) |
| Waits for pTask's reference count to become one. More...
|
|
void | waitForAll () |
| Waits for this MicroScheduler to have executed all it's tasks. More...
|
|
void | destoryTask (Task *pTask) |
| Manually destroy pTask. Undefined if this Task is executing.
|
|
GTS_INLINE void | setActiveState (bool isActive) |
| Sets the active state of this MicroScheduler. An active MicroScheduler will be run by the WorkerPool and a inactive MicroScheduler will be ignored. By default, an initialized MicroScheduler is active. More...
|
|
void | addExternalVictim (MicroScheduler *pScheduler) |
| Adds 'pScheduler' as an external victim. All Schedules in this MicroScheduler will be able to steal from pScheduler when they run out of work. More...
|
|
void | removeExternalVictim (MicroScheduler *pScheduler) |
| Removes 'pScheduler' as an external victim.
|
|
template<typename TFunc > |
void | registerCallback (MicroSchedulerCallbackType type, TFunc callback, void *pUserData) |
|
template<typename TFunc > |
void | unregisterCallback (MicroSchedulerCallbackType type, TFunc callback, void *pUserData) |
|
bool | stealAndExecuteTask () |
| Tries to steal and execute a Task. More...
|
|
bool | hasDemand (bool clear=false) const |
| Checks if the LocalScheduler mapped to this thread has demand. More...
|
|
bool | isRunning () const |
| Checks if the scheduler is running. More...
|
|
bool | hasTasks () const |
| Checks if the scheduler has tasks. More...
|
|
bool | hasExternalTasks () const |
| Checks if the scheduler has external tasks. More...
|
|
uint32_t | workerCount () const |
| Get the worker count of the WorkerPool this scheduler is attached to. More...
|
|
OwnedId | thisWorkerId () const |
| Get the worker the Worker ID of the calling thread. More...
|
|
void | wakeWorker () |
| Wake a sleeping Worker.
|
|
GTS_INLINE bool | isActive () const |
| Checks if the scheduler is active. More...
|
|
GTS_INLINE SubIdType | id () const |
| Get this schedulers ID. More...
|
|
A work-stealing task scheduler. The scheduler is executed by the WorkerPool it is initialized with.
Supports: -Help-first work-stealing -Fork-join with nested parallelism -Arbitrary DAGs -Blocking joins -Continuation joins -Scheduler by-passing and task recycling optimizations -Task affinities. (Force a task to run on a specific thread.) -Task priorities with starvation resistance -Scheduler partitioning -Task execution isolation -Hierarchical work-stealing via external victims.
- Todo:
Abstract into interface and make a concrete WorkStealingMicroScheduler. Interface will allow other algorithms to be explored.
Explore making priorities global to the scheduler. Currently they are only local to each thread.