hpx/synchronization/channel_mpsc.hpp#

Defined in header hpx/synchronization/channel_mpsc.hpp.

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

namespace hpx
namespace lcos
namespace local

Typedefs

template<typename T, channel_mode Mode = channel_mode::normal>
using channel_mpsc = base_channel_mpsc<T, hpx::spinlock, Mode>#
template<typename T, typename Mutex = hpx::util::spinlock, channel_mode = channel_mode::normal>
class base_channel_mpsc#

Public Functions

inline explicit base_channel_mpsc(std::size_t size)#
base_channel_mpsc(base_channel_mpsc const &rhs) = delete#
base_channel_mpsc &operator=(base_channel_mpsc const &rhs) = delete#
inline base_channel_mpsc(base_channel_mpsc &&rhs) noexcept#
inline base_channel_mpsc &operator=(base_channel_mpsc &&rhs) noexcept#
inline ~base_channel_mpsc()#
inline bool is_empty() const noexcept#
inline bool get(T *val = nullptr) const noexcept#
inline bool set(T &&t) noexcept(noexcept(std::declval<std::unique_lock<mutex_type>&>().lock()) && noexcept(std::declval<std::unique_lock<mutex_type>&>().unlock()))#
inline std::size_t close()#
inline constexpr std::size_t capacity() const noexcept#

Private Types

using mutex_type = Mutex#

Private Functions

inline bool is_full(std::size_t tail) const noexcept#
inline bool is_empty(std::size_t head) const noexcept#

Private Members

mutable hpx::util::cache_aligned_data<std::atomic<std::size_t>> head_#
mutable hpx::util::cache_aligned_data<std::size_t> tail_cached_#
hpx::util::cache_aligned_data<tail_data> tail_#
std::size_t size_#
std::unique_ptr<T[]> buffer_#
std::atomic<bool> closed_#
struct tail_data#

Public Members

mutex_type mtx_#
std::atomic<std::size_t> tail_#
template<typename T, typename Mutex>
class base_channel_mpsc<T, Mutex, channel_mode::dont_support_close>#
#include <channel_mpsc.hpp>

A bounded, lock-free MPSC channel without close support.

This implementation is based on Dmitry Vyukov’s bounded MPSC queue algorithm. The internal ring buffer capacity is rounded up to the nearest power of two (at least 8) using std::bit_ceil for sequence bitmasking. capacity() returns the requested size, matching the behavior of the normal base_channel_mpsc specialization; it represents a lower bound for the number of items the channel can hold.

Note

Mutex is an unused template parameter retained for compatibility with the primary template base_channel_mpsc<T, Mutex, Mode>.

Public Functions

inline explicit base_channel_mpsc(std::size_t size)#
base_channel_mpsc(base_channel_mpsc const &rhs) = delete#
base_channel_mpsc &operator=(base_channel_mpsc const &rhs) = delete#
inline base_channel_mpsc(base_channel_mpsc &&rhs) noexcept#
inline base_channel_mpsc &operator=(base_channel_mpsc &&rhs) noexcept#
~base_channel_mpsc() = default#
inline bool is_empty() const noexcept#
inline bool get(T *val = nullptr) const noexcept#
inline bool set(T &&t) noexcept#
inline constexpr std::size_t capacity() const noexcept#

Returns the requested capacity of the channel. This represents a lower bound for the number of items the channel can hold.

Private Members

mutable hpx::util::cache_aligned_data<std::atomic<std::size_t>> head_#
mutable hpx::util::cache_aligned_data<std::atomic<std::size_t>> tail_#
std::size_t size_ = 0#
std::size_t buffer_mask_ = 0#
std::unique_ptr<cell_type[]> buffer_#
template<>
struct cell_type#

Public Members

std::atomic<std::size_t> sequence_#
T data_#