olp-cpp-sdk
1.21.0
|
An abstract interface that is used as a base for the custom thread scheduling strategy. More...
#include <TaskScheduler.h>
Public Types | |
using | CallFuncType = std::function< void()> |
An alias for the abstract interface input. | |
Public Member Functions | |
void | ScheduleTask (CallFuncType &&func) |
Schedules the asynchronous task. More... | |
void | ScheduleTask (CallFuncType &&func, uint32_t priority) |
Schedules the asynchronous task. More... | |
template<class Function , typename std::enable_if<!std::is_convertible< decltype(std::declval< Function >()), CallFuncType >::value , ::type * = nullptr> | |
client::CancellationContext | ScheduleTask (Function &&func) |
Schedules the asynchronous cancellable task. More... | |
Protected Member Functions | |
virtual void | EnqueueTask (CallFuncType &&)=0 |
The abstract enqueue task interface that is implemented by the subclass. More... | |
virtual void | EnqueueTask (CallFuncType &&func, uint32_t priority) |
The enqueue task with priority interface that is implemented by the subclass. More... | |
An abstract interface that is used as a base for the custom thread scheduling strategy.
Subclasses should inherit from this class and implement virtual EnqueueTask
that takes any callable target (lambda expression, bind expression, or any other function object) as input and adds it to the execution pipeline.
|
protectedpure virtual |
The abstract enqueue task interface that is implemented by the subclass.
Implement this method in the subclass that takes TaskScheduler
as a base and provides a custom algorithm for scheduling tasks enqueued by the SDK.
Implemented in olp::thread::ThreadPoolTaskScheduler.
|
inlineprotectedvirtual |
The enqueue task with priority interface that is implemented by the subclass.
Implement this method in the subclass that takes TaskScheduler
as a base and provides a custom algorithm for scheduling tasks enqueued by the SDK. The method priorities tasks, so tasks with higher priority executed earlier. Tasks within the same priority group should keep the order.
[in] | func | The rvalue reference of the task that should be enqueued. Move this task into your queue. No internal references are kept. Once this method is called, you own the task. |
[in] | priority | The priority of the task. Tasks with higher priority executes earlier. |
Reimplemented in olp::thread::ThreadPoolTaskScheduler.
|
inline |
Schedules the asynchronous task.
[in] | func | The callable target that should be added to the scheduling pipeline. |
|
inline |
Schedules the asynchronous task.
[in] | func | The callable target that should be added to the scheduling pipeline. |
[in] | priority | The priority of the task. Tasks with higher priority executes earlier. |
|
inline |
Schedules the asynchronous cancellable task.
[in] | func | The callable target that should be added to the scheduling pipeline. As CancellationContext is created internally, it is passed as input, so the callable function should have the following signature: |
CancellationContext
copy to the caller. The copy can be used to cancel the enqueued tasks. Tasks can only be canceled before or during execution if the task itself is designed to support this. Tasks are also able to cancel the operation themselves as they get a non-const reference to the CancellationContext
class.