GlitchyByte Lib  0.3.1
GlitchyByte general library to bootstrap development.
Public Member Functions | List of all members
gb::TaskRunner Class Reference

Public Member Functions

 TaskRunner () noexcept
 
 ~TaskRunner () noexcept
 
bool isActive () const noexcept
 
void shutdown () noexcept
 
bool start (std::shared_ptr< Task > const &task) noexcept
 
void cancelAll () noexcept
 
void awaitAll () noexcept
 

Detailed Description

Task runner facility to run tasks in their own threads.

Note that start method will block until the task signals it has started. This is by design to ensure a task is ready to accept input, for example.

Constructor & Destructor Documentation

◆ TaskRunner()

gb::TaskRunner::TaskRunner ( )
inlinenoexcept

Creates a task runner.

◆ ~TaskRunner()

gb::TaskRunner::~TaskRunner ( )
inlinenoexcept

Destroys the task runner.

It shuts down the runner as per shutdown().

Member Function Documentation

◆ isActive()

bool gb::TaskRunner::isActive ( ) const
inlinenoexcept

Returns true if the runner is active and able to accept tasks.

Returns
True if the runner is active and able to accept tasks.

◆ shutdown()

void gb::TaskRunner::shutdown ( )
inlinenoexcept

Shuts down the runner.

Cancels all tasks and awaits on all tasks to stop.

◆ start()

bool gb::TaskRunner::start ( std::shared_ptr< Task > const &  task)
inlinenoexcept

Starts a task.

This method will block until the task signals it has started.

Parameters
taskTask to start.
Returns
True if the task was started, false if the runner is not active.

◆ cancelAll()

void gb::TaskRunner::cancelAll ( )
inlinenoexcept

Cancels all tasks.

◆ awaitAll()

void gb::TaskRunner::awaitAll ( )
inlinenoexcept

Awaits for all tasks to finish.


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