olp-cpp-sdk  1.19.0
Public Member Functions | Protected Member Functions | List of all members
olp::thread::ThreadPoolTaskScheduler Class Referencefinal

An implementation of the TaskScheduler instance that uses a thread pool. More...

#include <ThreadPoolTaskScheduler.h>

Inheritance diagram for olp::thread::ThreadPoolTaskScheduler:
Inheritance graph
[legend]
Collaboration diagram for olp::thread::ThreadPoolTaskScheduler:
Collaboration graph
[legend]

Public Member Functions

 ThreadPoolTaskScheduler (size_t thread_count=1u)
 Creates the ThreadPoolTaskScheduler object with one thread. More...
 
 ~ThreadPoolTaskScheduler () override
 Closes the SyncQueue instance and joins threads.
 
 ThreadPoolTaskScheduler (const ThreadPoolTaskScheduler &)=delete
 Non-copyable, non-movable.
 
ThreadPoolTaskScheduleroperator= (const ThreadPoolTaskScheduler &)=delete
 Non-copyable, non-movable.
 
 ThreadPoolTaskScheduler (ThreadPoolTaskScheduler &&)=delete
 Non-copyable, non-movable.
 
ThreadPoolTaskScheduleroperator= (ThreadPoolTaskScheduler &&)=delete
 Non-copyable, non-movable.
 
- Public Member Functions inherited from olp::thread::TaskScheduler
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

void EnqueueTask (TaskScheduler::CallFuncType &&func) override
 Overrides the base class method to enqueue tasks and execute them on the next free thread from the thread pool. More...
 
void EnqueueTask (TaskScheduler::CallFuncType &&func, uint32_t priority) override
 Overrides the base class method to enqueue tasks and execute them on the next free thread from the thread pool. More...
 

Additional Inherited Members

- Public Types inherited from olp::thread::TaskScheduler
using CallFuncType = std::function< void()>
 An alias for the abstract interface input.
 

Detailed Description

An implementation of the TaskScheduler instance that uses a thread pool.

Constructor & Destructor Documentation

◆ ThreadPoolTaskScheduler()

olp::thread::ThreadPoolTaskScheduler::ThreadPoolTaskScheduler ( size_t  thread_count = 1u)
explicit

Creates the ThreadPoolTaskScheduler object with one thread.

Parameters
thread_countThe number of threads initialized in the thread pool.

Member Function Documentation

◆ EnqueueTask() [1/2]

void olp::thread::ThreadPoolTaskScheduler::EnqueueTask ( TaskScheduler::CallFuncType &&  func)
overrideprotectedvirtual

Overrides the base class method to enqueue tasks and execute them on the next free thread from the thread pool.

Note
Tasks added with this method has Priority::NORMAL priority.
Parameters
funcThe 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.

Implements olp::thread::TaskScheduler.

◆ EnqueueTask() [2/2]

void olp::thread::ThreadPoolTaskScheduler::EnqueueTask ( TaskScheduler::CallFuncType &&  func,
uint32_t  priority 
)
overrideprotectedvirtual

Overrides the base class method to enqueue tasks and execute them on the next free thread from the thread pool.

Parameters
funcThe 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.
priorityThe priority of the task. Tasks with higher priority executes earlier.

Reimplemented from olp::thread::TaskScheduler.


The documentation for this class was generated from the following file: