Squid::Tasks 1.0.0
C++14 coroutine-based task library for games
|
Container for tracking decentralized state across multiple tasks. (See Token List for more info...) More...
#include <TokenList.h>
Public Types | |
using | Token = typename std::conditional_t< std::is_void< T >::value, Token, DataToken< T > > |
Type of Token tracked by this container. | |
Public Member Functions | |
template<typename U = T, typename std::enable_if_t< std::is_void< U >::value > * = nullptr> | |
std::shared_ptr< Token > | TakeToken (std::string in_name) |
Create and add a token with the specified debug name. | |
template<typename U = T, typename std::enable_if_t<!std::is_void< U >::value > * = nullptr> | |
std::shared_ptr< Token > | TakeToken (std::string in_name, U in_data) |
Create and add a token with the specified debug name and associated data. | |
std::shared_ptr< Token > | AddToken (std::shared_ptr< Token > in_token) |
Add an existing token to this container. | |
void | RemoveToken (std::shared_ptr< Token > in_token) |
Explicitly remove a token from this container. | |
operator bool () const | |
Convenience conversion operator that calls HasTokens() | |
bool | HasTokens () const |
Returns whether this container holds any live tokens. | |
std::vector< T > | GetTokenData () const |
Returns an array of all live token data. | |
std::string | GetDebugString () const |
Returns a debug string containing a list of the debug names of all live tokens. | |
Data Queries | |
Methods for querying and aggregating the data from the set of live tokens. | |
std::optional< T > | GetLeastRecent () const |
Returns associated data from the least-recently-added live token. | |
std::optional< T > | GetMostRecent () const |
Returns associated data from the most-recently-added live token. | |
std::optional< T > | GetMin () const |
Returns smallest associated data from the set of live tokens. | |
std::optional< T > | GetMax () const |
Returns largest associated data from the set of live tokens. | |
std::optional< double > | GetMean () const |
Returns arithmetic mean of all associated data from the set of live tokens. | |
template<typename U = T, typename std::enable_if_t<!std::is_void< U >::value > * = nullptr> | |
bool | Contains (const U &in_searchData) const |
Returns whether the set of live tokens contains at least one token associated with the specified data. | |
Static Public Member Functions | |
template<typename U = T, typename std::enable_if_t< std::is_void< U >::value > * = nullptr> | |
static std::shared_ptr< Token > | MakeToken (std::string in_name) |
Create a token with the specified debug name. | |
template<typename U = T, typename std::enable_if_t<!std::is_void< U >::value > * = nullptr> | |
static std::shared_ptr< Token > | MakeToken (std::string in_name, U in_data) |
Create a token with the specified debug name and associated data. | |
Container for tracking decentralized state across multiple tasks. (See Token List for more info...)
T | Type of data to associate with each Token in this container |