cpp-mate  0.7
Helpful library for C++.
CppMate::SharedState< T > Class Template Referencefinal

Represents shared state wrapper for thread pool tasks. More...

#include <SharedState.hpp>

Classes

class  Action
 Represents possible actions for modification of the state. More...
 

Public Member Functions

template<typename... A, typename = std::enable_if_t<std::is_constructible_v<T, A...>>>
 SharedState (A &&... args)
 Constructor. More...
 
void view (std::function< void(const T &)> block) const
 Provides read access to state within a block. More...
 
template<typename R >
view (std::function< R(const T &)> block) const
 Provides read access to state within a block and return value. More...
 
void modify (std::function< void(T &)> block)
 Provides read and write access to state within a block. More...
 
Action modify ()
 Provides read and write actions with state. More...
 

Detailed Description

template<typename T>
class CppMate::SharedState< T >

Represents shared state wrapper for thread pool tasks.

Constructor & Destructor Documentation

◆ SharedState()

template<typename T >
template<typename... A, typename = std::enable_if_t<std::is_constructible_v<T, A...>>>
CppMate::SharedState< T >::SharedState ( A &&...  args)
inline

Constructor.

Parameters
argsarguments to pass in T object constructor.

Member Function Documentation

◆ modify() [1/2]

template<typename T >
Action CppMate::SharedState< T >::modify ( )
inline

Provides read and write actions with state.

Returns
an action to choose.

◆ modify() [2/2]

template<typename T >
void CppMate::SharedState< T >::modify ( std::function< void(T &)>  block)
inline

Provides read and write access to state within a block.

Parameters
blockthe block function.

◆ view() [1/2]

template<typename T >
template<typename R >
R CppMate::SharedState< T >::view ( std::function< R(const T &)>  block) const
inline

Provides read access to state within a block and return value.

Parameters
blockthe block function.
Returns
result of the block call.

◆ view() [2/2]

template<typename T >
void CppMate::SharedState< T >::view ( std::function< void(const T &)>  block) const
inline

Provides read access to state within a block.

Parameters
blockthe block function.

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