Documentation Home >> Headers >> <jss/synchronized_value.hpp> Header >> jss::synchronized_value >> jss::synchronized_value::operator* pointer dereference operator

Provides synchronized access to the wrapped object.

unspecified operator*();


Given an object sv of type jss::synchronized_value<T>, a statement of the form T x=*sv requires that T is CopyConstructible, and *sv=x requires that T is MoveAssignable.


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

The expression *sv=x assigns the value x to the wrapped object.

The expression x=*sv copy-constructs a new T value from the wrapped object and assigns that to x.


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 bar() {
    X local={42};
    *x=local; // lock the mutex, do internal_value=local, unlock the mutex

#include <jss/synchronized_value.hpp>

See Also