AIStatefulTask ‐ Asynchronous, Stateful Task Scheduler library.

Threads-like task objects evolving through user-defined states.

Classes | Public Types | Public Member Functions | Public Attributes | Friends | List of all members
AIStatefulTask::Handler Struct Reference

Detailed Description

Describes if, how and where to run a task.

By constructing a Handler from Handler::idle, it describes that a task is idle, or that Handler is not to be used when other alternatives exist.

By constructing a Handler from Handler::immediate, it describes that a task should run in the thread that calls run() or the thread that wakes up a task by calling signal(). Hence, this handler causes a task to run to until the first time it goes idle, or calls yield, before returning from run / signal respectively.

When a Handler is constructed from an AIEngine pointer, then it describes that a task should run in that engine.

Finally, a Handler can be constructed from AIQueueHandle, describing that a task should run in the thread pool by adding it to the PriorityQueue of that handle.

#include <AIStatefulTask.h>

Collaboration diagram for AIStatefulTask::Handler:
Collaboration graph
[legend]

Classes

union  Handle
 Contains extra data that depends on the type of the Handler. More...
 

Public Types

enum  type_t { idle_h , immediate_h , engine_h , thread_pool_h }
 The type of m_type. More...
 
enum  special_t { idle = idle_h , immediate = immediate_h }
 A typed use by the constuctor Handler(special_t). More...
 

Public Member Functions

 Handler (special_t special)
 Construct a special Handler.
 
 Handler (AIEngine *engine)
 Construct a Handler from an AIEngine pointer.
 
 Handler (AIQueueHandle queue_handle)
 Construct a Handler from an AIQueueHandle.
 
bool is_engine () const
 Return true if this is an engine Handler.
 
bool is_immediate () const
 Return true if this is an immediate Handler.
 
bool is_thread_pool () const
 Return true if this is a thread pool handler.
 
AIQueueHandle get_queue_handle () const
 Return the AIQueueHandle to use (only call when appropriate).
 
 operator bool () const
 Return true when not idle / unused.
 
bool operator== (Handler handler) const
 Return true when equivalent to handler.
 
bool operator!= (Handler handler) const
 

Public Attributes

Handle m_handle
 Extra data that depends on m_type.
 
type_t m_type
 The type of this Handler.
 

Friends

std::ostream & operator<< (std::ostream &os, Handler const &handler)
 Write a Handler to an ostream.
 

Member Enumeration Documentation

◆ special_t

A typed use by the constuctor Handler(special_t).

Enumerator
idle 

Construct an idle Handler.

immediate 

Construct an immediate Handler.

◆ type_t

The type of m_type.

Enumerator
idle_h 

An idle Handler.

immediate_h 

An immediate Handler.

engine_h 

An engine Handler.

thread_pool_h 

A thread pool Handler.


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