Kagome
Polkadot Runtime Engine in C++17
SafeObject< T, M > Struct Template Reference

#include <safe_object.hpp>

Inheritance diagram for SafeObject< T, M >:
Collaboration diagram for SafeObject< T, M >:

Public Member Functions

template<typename... Args>
 SafeObject (Args &&...args)
 
template<typename F >
auto exclusiveAccess (F &&f)
 
template<typename F >
auto sharedAccess (F &&f) const
 

Private Attributes

t_
 
cs_
 

Detailed Description

template<typename T, typename M = std::shared_mutex>
struct SafeObject< T, M >

Copyright Soramitsu Co., Ltd. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 Protected object wrapper. Allow read-write access.

Template Parameters
Tobject type Example:
bool const is_one_att1 =
obj.sharedAccess([](auto const &str) {
return str == "1";
});
obj.exclusiveAccess([](auto &str) {
str = "2";
});
bool const is_one_att2 =
obj.sharedAccess([](auto const &str) {
return str == "1";
});
std::cout <<
"Attempt 1: " << is_one_att1 << std::endl <<
"Attempt 2: " << is_one_att2;

Definition at line 38 of file safe_object.hpp.

Constructor & Destructor Documentation

template<typename T, typename M = std::shared_mutex>
template<typename... Args>
SafeObject< T, M >::SafeObject ( Args &&...  args)
inline

Definition at line 40 of file safe_object.hpp.

Member Function Documentation

template<typename T, typename M = std::shared_mutex>
template<typename F >
auto SafeObject< T, M >::exclusiveAccess ( F &&  f)
inline

Definition at line 43 of file safe_object.hpp.

template<typename T, typename M = std::shared_mutex>
template<typename F >
auto SafeObject< T, M >::sharedAccess ( F &&  f) const
inline

Definition at line 49 of file safe_object.hpp.

Member Data Documentation

template<typename T, typename M = std::shared_mutex>
M SafeObject< T, M >::cs_
mutableprivate

Definition at line 56 of file safe_object.hpp.

template<typename T, typename M = std::shared_mutex>
T SafeObject< T, M >::t_
private

Definition at line 55 of file safe_object.hpp.


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