Support Class Library
A set of tools providing classes and utility
All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
scl::async::Active Class Reference

A class that allow task execution on a separate thread using RAII semantics. More...

#include "Active.h"

Collaboration diagram for scl::async::Active:
Collaboration graph
[legend]

Public Types

using message_type = std::function< void()>
 The type of messages sent through the queue. More...
 
using thread_type = std::thread
 The type of threads used to execute the tasks. More...
 
using flag_type = std::atomic_bool
 The type of flags used for completion checks. More...
 
using message_queue_type = Channel< message_type >
 The type of queue used to send messages. More...
 

Public Member Functions

 Active ()
 Construct an active object (starts spinning the queue) More...
 
 ~Active ()
 Destroy an active object (finishing the queue) More...
 
void execute (message_type msg)
 Execute a task via the active object. More...
 

Protected Attributes

flag_type done
 The flag determining whether or not we should execute more tasks. More...
 
message_queue_type mq
 The queue used to transfer messages. More...
 
thread_type thread
 The worker thread used to execute tasks. More...
 

Detailed Description

A class that allow task execution on a separate thread using RAII semantics.

Definition at line 13 of file Active.h.

Member Typedef Documentation

◆ flag_type

The type of flags used for completion checks.

Definition at line 31 of file Active.h.

◆ message_queue_type

The type of queue used to send messages.

Definition at line 37 of file Active.h.

◆ message_type

The type of messages sent through the queue.

Definition at line 19 of file Active.h.

◆ thread_type

The type of threads used to execute the tasks.

Definition at line 25 of file Active.h.

Constructor & Destructor Documentation

◆ Active()

scl::async::Active::Active ( )
inline

Construct an active object (starts spinning the queue)

Definition at line 59 of file Active.h.

◆ ~Active()

scl::async::Active::~Active ( )
inline

Destroy an active object (finishing the queue)

Definition at line 69 of file Active.h.

Member Function Documentation

◆ execute()

void scl::async::Active::execute ( message_type  msg)
inline

Execute a task via the active object.

Parameters
msgbeing the task to execute

Definition at line 81 of file Active.h.

Member Data Documentation

◆ done

flag_type scl::async::Active::done
protected

The flag determining whether or not we should execute more tasks.

Definition at line 43 of file Active.h.

◆ mq

message_queue_type scl::async::Active::mq
protected

The queue used to transfer messages.

Definition at line 48 of file Active.h.

◆ thread

thread_type scl::async::Active::thread
protected

The worker thread used to execute tasks.

Definition at line 53 of file Active.h.


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