libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::task::SequencedTaskRunner Class Reference

#include <task_runner.hpp>

Inheritance diagram for fly::task::SequencedTaskRunner:
Collaboration diagram for fly::task::SequencedTaskRunner:

Static Public Member Functions

static std::shared_ptr< SequencedTaskRunnercreate (std::shared_ptr< TaskManager > task_manager)
 

Protected Member Functions

 SequencedTaskRunner (std::shared_ptr< TaskManager > task_manager) noexcept
 
bool post_task_internal (TaskLocation &&location, Task &&task) override
 
void task_complete (TaskLocation &&location) override
 
- Protected Member Functions inherited from fly::task::TaskRunner
 TaskRunner (std::shared_ptr< TaskManager > task_manager) noexcept
 
bool post_task_to_task_manager (TaskLocation &&location, Task &&task)
 
bool post_task_to_task_manager_with_delay (TaskLocation &&location, std::chrono::milliseconds delay, Task &&task)
 

Additional Inherited Members

- Public Member Functions inherited from fly::task::TaskRunner
virtual ~TaskRunner ()=default
 
template<typename TaskType >
bool post_task (TaskLocation &&location, TaskType &&task)
 
template<typename OwnerType , typename TaskType >
bool post_task (TaskLocation &&location, std::weak_ptr< OwnerType > weak_owner, TaskType &&task)
 
template<typename TaskType , typename ReplyType >
bool post_task_with_reply (TaskLocation &&location, TaskType &&task, ReplyType &&reply)
 
template<typename OwnerType , typename TaskType , typename ReplyType >
bool post_task_with_reply (TaskLocation &&location, std::weak_ptr< OwnerType > weak_owner, TaskType &&task, ReplyType &&reply)
 
template<typename TaskType >
bool post_task_with_delay (TaskLocation &&location, std::chrono::milliseconds delay, TaskType &&task)
 
template<typename OwnerType , typename TaskType >
bool post_task_with_delay (TaskLocation &&location, std::weak_ptr< OwnerType > weak_owner, std::chrono::milliseconds delay, TaskType &&task)
 
template<typename TaskType , typename ReplyType >
bool post_task_with_delay_and_reply (TaskLocation &&location, std::chrono::milliseconds delay, TaskType &&task, ReplyType &&reply)
 
template<typename OwnerType , typename TaskType , typename ReplyType >
bool post_task_with_delay_and_reply (TaskLocation &&location, std::weak_ptr< OwnerType > weak_owner, std::chrono::milliseconds delay, TaskType &&task, ReplyType &&reply)
 

Detailed Description

Task runner implementation for executing tasks in sequence. Only one task posted to this task runner will execute at a time. Tasks are executed in a FIFO manner; once one task completes, the next task in line will be posted for execution.

The caveat is with delayed tasks. If task A is posted with some delay, then task B is posted with no delay, task B will be posted for execution first. Task A will only be posted for execution once its delay has expired.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
August 12, 2018

Member Function Documentation

◆ create()

std::shared_ptr< SequencedTaskRunner > fly::task::SequencedTaskRunner::create ( std::shared_ptr< TaskManager task_manager)
static

Create a sequenced task runner.

Parameters
task_managerThe task manager this runner should interface with.
Returns
The created task runner.

◆ post_task_internal()

bool fly::task::SequencedTaskRunner::post_task_internal ( TaskLocation &&  location,
Task &&  task 
)
overrideprotectedvirtual

Post a task for execution within this sequence. If a task is not already running, the task is posted for execution immediately. Otherwise, the task is queued until the currently running task (and all tasks queued before it) have completed.

Parameters
locationThe location from which the task was posted.
taskThe task to be executed.
Returns
True if the task was posted for execution.

Implements fly::task::TaskRunner.

◆ task_complete()

void fly::task::SequencedTaskRunner::task_complete ( TaskLocation &&  location)
overrideprotectedvirtual

When a task is complete, post the next task in the pending queue.

Parameters
locationThe location from which the task was posted.

Implements fly::task::TaskRunner.


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