CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
PriorityChannel< T, P > Class Template Reference

Prioritized thread communication channel. More...

#include <cc/PriorityChannel>

Public Types

using Item = T
 Item type.
 
using Priority = P
 Priority type.
 

Public Member Functions

 PriorityChannel ()=default
 Create a new channel.
 
bool pushBack (const T &item, P priority=0)
 Add a new item to the end.
 
bool popFront (Out< T > item=None{})
 Remove an item from the front.
 
bool read (Out< T > item)
 Remove an item from the front.
 
bool write (const T &item, P priority=0)
 Add a new item to the end.
 
bool wait ()
 Wait for the channel to become ready to read.
 
bool waitUntil (double time)
 Wait for the channel to become ready to read for a limited time.
 
bool popFrontBefore (double time, Out< T > item=None{})
 Remove an item from the head of the queue before given time.
 
long count () const
 Get the number of queued items.
 
void close ()
 Shutdown communication.
 
SourceIterator< PriorityChannelbegin ()
 
SourceIterator< PriorityChannelend ()
 

Detailed Description

template<class T, class P = int>
class cc::PriorityChannel< T, P >

Prioritized thread communication channel.

Template Parameters
TItem type
PPriority type

Member Typedef Documentation

◆ Item

template<class T , class P = int>
using Item = T

Item type.

◆ Priority

template<class T , class P = int>
using Priority = P

Priority type.

Constructor & Destructor Documentation

◆ PriorityChannel()

template<class T , class P = int>
PriorityChannel ( )
default

Create a new channel.

Member Function Documentation

◆ pushBack()

template<class T , class P = int>
bool pushBack ( const T & item,
P priority = 0 )

Add a new item to the end.

Parameters
itemItem value
priorityItem priority
Returns
True if successful

◆ popFront()

template<class T , class P = int>
bool popFront ( Out< T > item = None{})

Remove an item from the front.

Parameters
itemReturns the item value
Returns
True if successful

◆ read()

template<class T , class P = int>
bool read ( Out< T > item)

Remove an item from the front.

Parameters
itemReturns the item value
Returns
True if successful

◆ write()

template<class T , class P = int>
bool write ( const T & item,
P priority = 0 )

Add a new item to the end.

Parameters
itemItem value
priorityItem priority
Returns
True if successful

◆ wait()

template<class T , class P = int>
bool wait ( )

Wait for the channel to become ready to read.

Returns
True if successful

◆ waitUntil()

template<class T , class P = int>
bool waitUntil ( double time)

Wait for the channel to become ready to read for a limited time.

Parameters
timeSeconds elapsed since the begin of Epoch
Returns
True if successful
See also
System::now()

◆ popFrontBefore()

template<class T , class P = int>
bool popFrontBefore ( double time,
Out< T > item = None{} )

Remove an item from the head of the queue before given time.

Parameters
timeSeconds elapsed since the begin of Epoch
itemReturns the item value
Returns
True if successful
See also
System::now()

◆ count()

template<class T , class P = int>
long count ( ) const

Get the number of queued items.

◆ close()

template<class T , class P = int>
void close ( )

Shutdown communication.