Leosac
0.8.0
Open Source Access Control
|
This is a scheduler that is used internally to schedule asynchronous / long running tasks. More...
#include <Scheduler.hpp>
Public Member Functions | |
Scheduler (Kernel *kptr) | |
Construct a scheduler object (generally 1 per application). More... | |
Scheduler (const Scheduler &)=delete | |
Scheduler (Scheduler &&)=delete | |
Scheduler & | operator= (const Scheduler &)=delete |
Scheduler & | operator= (Scheduler &&)=delete |
template<typename Callable > | |
std::enable_if< !std::is_convertible< Callable, std::shared_ptr< Tasks::Task > >::value, void >::type | enqueue (const Callable &call, TargetThread policy) |
void | enqueue (Tasks::TaskPtr t, TargetThread policy) |
Enqueue a task, a schedule to run on thread policy . More... | |
void | update (TargetThread me) noexcept |
This will run queued tasks that are scheduled to run on thread me . More... | |
void | register_thread (TargetThread me) |
This is currently useless. More... | |
Kernel & | kernel () |
Retrieve the kernel reference associated with the scheduler. More... | |
Private Types | |
using | TaskQueue = std::queue< Tasks::TaskPtr > |
using | TaskQueueMap = std::map< TargetThread, TaskQueue > |
Private Attributes | |
TaskQueueMap | queues_ |
The internal queues of tasks. More... | |
Kernel * | kptr_ |
std::mutex | mutex_ |
This is a scheduler that is used internally to schedule asynchronous / long running tasks.
It currently support running a task on the main thread, or in some random thread.
The scheduler is fully thread-safe.
Definition at line 47 of file Scheduler.hpp.
|
private |
Definition at line 98 of file Scheduler.hpp.
|
private |
Definition at line 99 of file Scheduler.hpp.
Scheduler::Scheduler | ( | Kernel * | kptr | ) |
Construct a scheduler object (generally 1 per application).
The kptr
pointer should never be null, except when writing test cases.
Definition at line 67 of file Scheduler.cpp.
|
delete |
|
delete |
|
inline |
Definition at line 67 of file Scheduler.hpp.
void Scheduler::enqueue | ( | Tasks::TaskPtr | t, |
TargetThread | policy | ||
) |
Enqueue a task, a schedule to run on thread policy
.
Definition at line 29 of file Scheduler.cpp.
Kernel & Scheduler::kernel | ( | ) |
Retrieve the kernel reference associated with the scheduler.
This function will crash the application if the kernel pointer is null.
Definition at line 72 of file Scheduler.cpp.
void Scheduler::register_thread | ( | TargetThread | me | ) |
This is currently useless.
Definition at line 60 of file Scheduler.cpp.
|
noexcept |
This will run queued tasks that are scheduled to run on thread me
.
Definition at line 42 of file Scheduler.cpp.
|
private |
Definition at line 110 of file Scheduler.hpp.
|
mutableprivate |
Definition at line 111 of file Scheduler.hpp.
|
private |
The internal queues of tasks.
Each target thread has its own queue. Tasks scheduled to run on POOL
are not queued here, since they run on some detached thread we don't care about.
Definition at line 108 of file Scheduler.hpp.