|
| synchronized_value () |
| Default constructor. More...
|
|
| synchronized_value (T const &other) |
| Constructor from copy constructible value. More...
|
|
| synchronized_value (BOOST_THREAD_RV_REF(T) other) |
| Move Constructor. More...
|
|
| synchronized_value (synchronized_value const &rhs) |
| Constructor from value type. More...
|
|
| synchronized_value (BOOST_THREAD_RV_REF(synchronized_value) other) |
| Move Constructor from movable value type. More...
|
|
synchronized_value & | operator= (synchronized_value const &rhs) |
| Assignment operator. More...
|
|
synchronized_value & | operator= (value_type const &val) |
| Assignment operator from a T const&. More...
|
|
T | get () const |
| Explicit conversion to value type. More...
|
|
| operator T () const |
| Explicit conversion to value type. More...
|
|
T const & | value () const |
| value type getter. More...
|
|
mutex_type const & | mutex () const |
| mutex getter. More...
|
|
void | swap (synchronized_value &rhs) |
| Swap. More...
|
|
void | swap (value_type &rhs) |
| Swap with the underlying value type. More...
|
|
strict_lock_ptr< T, Lockable > | operator-> () |
| Essentially calling a method obj->foo(x, y, z) calls the method foo(x, y, z) inside a critical section as long-lived as the call itself. More...
|
|
const_strict_lock_ptr< T,
Lockable > | operator-> () const |
| If the synchronized_value object involved is const-qualified, then you'll only be able to call const methods through operator->. More...
|
|
template<typename F > |
boost::result_of< F(value_type &)>
::type | operator() (BOOST_THREAD_RV_REF(F) fct) |
| Call function on a locked block. More...
|
|
template<typename F > |
boost::result_of< F(value_type
const &)>::type | operator() (BOOST_THREAD_RV_REF(F) fct) const |
|
strict_lock_ptr< T, Lockable > | synchronize () |
| The synchronize() factory make easier to lock on a scope. More...
|
|
const_strict_lock_ptr< T,
Lockable > | synchronize () const |
|
unique_lock_ptr< T, Lockable > | unique_synchronize () |
|
const_unique_lock_ptr< T,
Lockable > | unique_synchronize () const |
|
unique_lock_ptr< T, Lockable > | unique_synchronize (defer_lock_t tag) |
|
const_unique_lock_ptr< T,
Lockable > | unique_synchronize (defer_lock_t tag) const |
|
unique_lock_ptr< T, Lockable > | defer_synchronize () BOOST_NOEXCEPT |
|
const_unique_lock_ptr< T,
Lockable > | defer_synchronize () const BOOST_NOEXCEPT |
|
unique_lock_ptr< T, Lockable > | try_to_synchronize () BOOST_NOEXCEPT |
|
const_unique_lock_ptr< T,
Lockable > | try_to_synchronize () const BOOST_NOEXCEPT |
|
unique_lock_ptr< T, Lockable > | adopt_synchronize () BOOST_NOEXCEPT |
|
const_unique_lock_ptr< T,
Lockable > | adopt_synchronize () const BOOST_NOEXCEPT |
|
deref_value | operator* () |
|
const_deref_value | operator* () const |
|
template<typename OStream > |
void | save (OStream &os) const |
| T is OutputStreamable saves the value type on the output stream os . More...
|
|
template<typename IStream > |
void | load (IStream &is) const |
| T is InputStreamable loads the value type from the input stream is . More...
|
|
bool | operator== (synchronized_value const &rhs) const |
| T is EqualityComparable More...
|
|
bool | operator< (synchronized_value const &rhs) const |
| T is LessThanComparable More...
|
|
bool | operator> (synchronized_value const &rhs) const |
| T is GreaterThanComparable More...
|
|
bool | operator<= (synchronized_value const &rhs) const |
|
bool | operator>= (synchronized_value const &rhs) const |
|
bool | operator== (value_type const &rhs) const |
|
bool | operator!= (value_type const &rhs) const |
|
bool | operator< (value_type const &rhs) const |
|
bool | operator<= (value_type const &rhs) const |
|
bool | operator> (value_type const &rhs) const |
|
bool | operator>= (value_type const &rhs) const |
|
template<typename T, typename Lockable = mutex>
class boost::synchronized_value< T, Lockable >
cloaks a value type and the mutex used to protect it together.
- Parameters
-
T | the value type. |
Lockable | the mutex type protecting the value type. |
template<typename T, typename Lockable = mutex>
Swap.
Effects: Swaps the data. Again, locks are acquired using lock(). The mutexes are not swapped. A swap method accepts a T& and swaps the data inside a critical section. This is by far the preferred method of changing the guarded datum wholesale because it keeps the lock only for a short time, thus lowering the pressure on the mutex.
References boost::defer_lock, boost::lock(), and boost::swap.
Referenced by boost::swap().
template<typename T, typename Lockable = mutex>
The synchronize() factory make easier to lock on a scope.
As discussed, operator-> can only lock over the duration of a call, so it is insufficient for complex operations. With synchronize() you get to lock the object in a scoped and to directly access the object inside that scope.
Example void fun(synchronized_value<vector<int>> & v) { auto&& vec=v.synchronize(); vec.push_back(42); assert(vec.back() == 42); }