hpx/synchronization/async_rw_mutex.hpp

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace experimental
template<typename ReadWriteT, typename ReadT, typename Allocator>
class async_rw_mutex
#include <async_rw_mutex.hpp>

Read-write mutex where access is granted to a value through senders.

The wrapped value is accessed through read and readwrite, both of which return senders which call set_value on a connected receiver when the wrapped value is safe to read or write. The senders send the value through a wrapper type which is implicitly convertible to a reference of the wrapped value. Read-only senders send wrappers that are convertible to const references.

A read-write sender gives exclusive access to the wrapped value, while a read-only sender gives shared (with other read-only senders) access to the value.

A void mutex acts as a mutex around some user-managed resource, i.e. the void mutex does not manage any value and the types sent by the senders are not convertible. The sent types are copyable and release access to the protected resource when released.

The order in which senders call set_value is determined by the order in which the senders are retrieved from the mutex. Connecting and starting the senders is thread-safe.

Retrieving senders from the mutex is not thread-safe.

The mutex is movable and non-copyable.

Public Types

template<>
using read_type = std::decay_t<ReadT> const
template<>
using readwrite_type = std::decay_t<ReadWriteT>
template<>
using value_type = readwrite_type
template<>
using read_access_type = detail::async_rw_mutex_access_wrapper<readwrite_type, read_type, detail::async_rw_mutex_access_type::read>
template<>
using readwrite_access_type = detail::async_rw_mutex_access_wrapper<readwrite_type, read_type, detail::async_rw_mutex_access_type::readwrite>
template<>
using allocator_type = Allocator

Public Functions

async_rw_mutex()
template<typename U, typename = std::enable_if_t<!std::is_same<std::decay_t<U>, async_rw_mutex>::value>>
async_rw_mutex(U &&u, allocator_type const &alloc = {})
async_rw_mutex(async_rw_mutex&&)
async_rw_mutex &operator=(async_rw_mutex&&)
async_rw_mutex(async_rw_mutex const&)
async_rw_mutex &operator=(async_rw_mutex const&)
sender<detail::async_rw_mutex_access_type::read> read()
sender<detail::async_rw_mutex_access_type::readwrite> readwrite()

Private Types

template<>
using shared_state_type = detail::async_rw_mutex_shared_state<value_type>
template<>
using shared_state_ptr_type = std::shared_ptr<shared_state_type>

Private Members

value_type value
allocator_type alloc
detail::async_rw_mutex_access_type prev_access = detail::async_rw_mutex_access_type::readwrite
shared_state_ptr_type prev_state
shared_state_ptr_type state
template<detail::async_rw_mutex_access_type AccessType>
struct sender

Public Types

template<>
template<>
using access_type = detail::async_rw_mutex_access_wrapper<readwrite_type, read_type, AccessType>

Public Members

template<>
shared_state_ptr_type prev_state
template<>
shared_state_ptr_type state

Friends

template<typename Env>
auto tag_invoke(hpx::execution::experimental::get_completion_signatures_t, sender const&, Env)
template<typename R>
auto tag_invoke(hpx::execution::experimental::connect_t, sender &&s, R &&r)
template<typename Env>
struct generate_completion_signatures

Public Types

template<>
template<>
template<template<typename...> typename Tuple, template<typename...> typename Variant>
using value_types = Variant<Tuple<access_type>>
template<>
template<>
template<template<typename...> typename Variant>
using error_types = Variant<std::exception_ptr>

Public Static Attributes

template<>
template<>
constexpr bool sends_stopped = false
template<typename R>
struct operation_state

Public Functions

template<>
template<typename R_>
operation_state(R_ &&r, shared_state_ptr_type prev_state, shared_state_ptr_type state)
template<>
template<>
operation_state(operation_state&&)
template<>
template<>
operation_state &operator=(operation_state&&)
template<>
template<>
operation_state(operation_state const&)
template<>
template<>
operation_state &operator=(operation_state const&)

Public Members

template<>
template<>
std::decay_t<R> r
template<>
template<>
shared_state_ptr_type prev_state
template<>
template<>
shared_state_ptr_type state

Friends

void tag_invoke(hpx::execution::experimental::start_t, operation_state &os)
template<typename Allocator>
class async_rw_mutex<void, void, Allocator>

Public Types

template<>
using read_type = void
template<>
using readwrite_type = void
template<>
using read_access_type = detail::async_rw_mutex_access_wrapper<readwrite_type, read_type, detail::async_rw_mutex_access_type::read>
template<>
using readwrite_access_type = detail::async_rw_mutex_access_wrapper<readwrite_type, read_type, detail::async_rw_mutex_access_type::readwrite>
template<>
using allocator_type = Allocator

Public Functions

async_rw_mutex(allocator_type const &alloc = {})
async_rw_mutex(async_rw_mutex&&)
async_rw_mutex &operator=(async_rw_mutex&&)
async_rw_mutex(async_rw_mutex const&)
async_rw_mutex &operator=(async_rw_mutex const&)
sender<detail::async_rw_mutex_access_type::read> read()
sender<detail::async_rw_mutex_access_type::readwrite> readwrite()

Private Types

template<>
using shared_state_type = detail::async_rw_mutex_shared_state<void>
template<>
using shared_state_ptr_type = std::shared_ptr<shared_state_type>

Private Members

allocator_type alloc
detail::async_rw_mutex_access_type prev_access = detail::async_rw_mutex_access_type::readwrite
shared_state_ptr_type prev_state
shared_state_ptr_type state
template<detail::async_rw_mutex_access_type AccessType>
struct sender

Public Types

template<>
template<>
using access_type = detail::async_rw_mutex_access_wrapper<readwrite_type, read_type, AccessType>

Public Members

template<>
shared_state_ptr_type prev_state
template<>
shared_state_ptr_type state

Friends

template<typename Env>
auto tag_invoke(hpx::execution::experimental::get_completion_signatures_t, sender const&, Env)
template<typename R>
auto tag_invoke(hpx::execution::experimental::connect_t, sender &&s, R &&r)
template<typename Env>
struct generate_completion_signatures

Public Types

template<>
template<>
template<template<typename...> typename Tuple, template<typename...> typename Variant>
using value_types = Variant<Tuple<access_type>>
template<>
template<>
template<template<typename...> typename Variant>
using error_types = Variant<std::exception_ptr>

Public Static Attributes

template<>
template<>
constexpr bool sends_stopped = false
template<typename R>
struct operation_state

Public Functions

template<>
template<typename R_>
operation_state(R_ &&r, shared_state_ptr_type prev_state, shared_state_ptr_type state)
template<>
template<>
operation_state(operation_state&&)
template<>
template<>
operation_state &operator=(operation_state&&)
template<>
template<>
operation_state(operation_state const&)
template<>
template<>
operation_state &operator=(operation_state const&)

Public Members

template<>
template<>
std::decay_t<R> r
template<>
template<>
shared_state_ptr_type prev_state
template<>
template<>
shared_state_ptr_type state

Friends

void tag_invoke(hpx::execution::experimental::start_t, operation_state &os)