Documentation Home >> Headers >> <jss/synchronized_value.hpp> Header >> jss::synchronized_value >> jss::synchronized_value::operator-> member access operator

Provides synchronized access to the wrapped object.

unspecified operator->();


Given an object sv of type jss::synchronized_value<T>, and an object p of type T*, sv->'['some-expr] is valid if and only if p->`some-expr would be valid.


Locks the internal mutex associated with *this and returns an object that implements the member access operator to access the wrapped T object. Unlocks the internal mutex at the end of the full expression.


Multiple accesses to the same jss::synchronized_value object within the same full expression will lead to deadlock.


std::system_error if the lock could not be acquired.


Multiple threads may call operator->() or operator*() on the same instance of jss::synchronized_value concurrently without external synchronization. If multiple threads call operator->() or operator*() concurrently on the same instance then the behaviour is as-if they each made their call in some unspecified order. The completion of the full expression associated with one access synchronizes-with a subsequent access to the wrapped object through *this.

struct X {
    int i;

jss::synchronized_value<X> x;

void foo() {
    x->i=3; // Lock the mutex, do internal_value.i=3, unlock the mutex

#include <jss/synchronized_value.hpp>

See Also