concurrency¶
The contents of this module can be included with the header
hpx/modules/concurrency.hpp
. These headers may be used by user-code but are not
guaranteed stable (neither header location nor contents). You are using these at
your own risk. If you wish to use non-public functionality from a module we
strongly suggest only including the module header hpx/modules/concurrency.hpp
, not
the particular header in which the functionality you would like to use is
defined. See Public API for a list of names that are part of the public
HPX API.
-
namespace
hpx
-
template<typename
Data
>
structcache_aligned_data
<Data, std::false_type>¶ Public Functions
-
cache_aligned_data
()¶
-
cache_aligned_data
(Data &&data)¶
-
cache_aligned_data
(Data const &data)¶
Public Members
-
Data
data_
¶
-
-
namespace
hpx
-
namespace
threads
-
namespace
util
-
-
template<typename
Data
, typenameNeedsPadding
= typename detail::needs_padding<Data>::type>
structcache_aligned_data
¶ Public Functions
-
cache_aligned_data
()
-
cache_aligned_data
(Data &&data)
-
cache_aligned_data
(Data const &data)
-
-
template<typename
Data
>
structcache_aligned_data
<Data, std::false_type> Public Functions
-
cache_aligned_data
()
-
cache_aligned_data
(Data &&data)
-
cache_aligned_data
(Data const &data)
Public Members
-
Data
data_
-
-
template<typename
Data
, typenameNeedsPadding
= typename detail::needs_padding<Data>::type>
structcache_aligned_data_derived
: public Data¶ Public Functions
-
cache_aligned_data_derived
()
-
cache_aligned_data_derived
(Data &&data)
-
cache_aligned_data_derived
(Data const &data)
Public Members
-
template<>
charcacheline_pad
[get_cache_line_padding_size
(sizeof(Data))]¶
-
-
template<typename
-
namespace
Defines
-
MOODYCAMEL_THREADLOCAL
¶
-
MOODYCAMEL_EXCEPTIONS_ENABLED
¶
-
MOODYCAMEL_TRY
¶
-
MOODYCAMEL_CATCH
(...)¶
-
MOODYCAMEL_RETHROW
¶
-
MOODYCAMEL_THROW
(expr)¶
-
MOODYCAMEL_NOEXCEPT
¶
-
MOODYCAMEL_NOEXCEPT_CTOR
(type, valueType, expr)¶
-
MOODYCAMEL_NOEXCEPT_ASSIGN
(type, valueType, expr)¶
-
MOODYCAMEL_DELETE_FUNCTION
¶
-
namespace
hpx
-
namespace
concurrency
¶ Functions
-
template<typename
T
, typenameTraits
>
voidswap
(typename ConcurrentQueue<T, Traits>::ImplicitProducerKVP &a, typename ConcurrentQueue<T, Traits>::ImplicitProducerKVP &b)¶
-
template<typename
T
, typenameTraits
>
voidswap
(ConcurrentQueue<T, Traits> &a, ConcurrentQueue<T, Traits> &b)¶
-
void
swap
(ProducerToken &a, ProducerToken &b)¶
-
void
swap
(ConsumerToken &a, ConsumerToken &b)¶
-
template<typename
T
, typenameTraits
= ConcurrentQueueDefaultTraits>
classConcurrentQueue
¶ Public Types
-
typedef ::hpx::concurrency::ProducerToken
producer_token_t
¶
-
typedef ::hpx::concurrency::ConsumerToken
consumer_token_t
¶
-
typedef Traits::index_t
index_t
¶
-
typedef Traits::size_t
size_t
¶
Public Functions
-
ConcurrentQueue
(size_t capacity = 6 * BLOCK_SIZE)¶
-
~ConcurrentQueue
()¶
-
ConcurrentQueue
(ConcurrentQueue const&)¶
-
ConcurrentQueue &
operator=
(ConcurrentQueue const&)¶
-
ConcurrentQueue
(ConcurrentQueue &&other)¶
-
ConcurrentQueue &
operator=
(ConcurrentQueue &&other)¶
-
void
swap
(ConcurrentQueue &other)¶
-
bool
enqueue
(T const &item)¶
-
bool
enqueue
(T &&item)¶
-
bool
enqueue
(producer_token_t const &token, T const &item)¶
-
bool
enqueue
(producer_token_t const &token, T &&item)¶
-
template<typename
It
>
boolenqueue_bulk
(producer_token_t const &token, It itemFirst, size_t count)¶
-
bool
try_enqueue
(T const &item)¶
-
bool
try_enqueue
(T &&item)¶
-
bool
try_enqueue
(producer_token_t const &token, T const &item)¶
-
bool
try_enqueue
(producer_token_t const &token, T &&item)¶
-
template<typename
It
>
booltry_enqueue_bulk
(producer_token_t const &token, It itemFirst, size_t count)¶
-
template<typename
U
>
booltry_dequeue
(consumer_token_t &token, U &item)¶
-
template<typename
It
>
size_ttry_dequeue_bulk
(consumer_token_t &token, It itemFirst, size_t max)¶
-
template<typename
U
>
booltry_dequeue_from_producer
(producer_token_t const &producer, U &item)¶
-
template<typename
It
>
size_ttry_dequeue_bulk_from_producer
(producer_token_t const &producer, It itemFirst, size_t max)¶
Public Static Functions
-
static bool
is_lock_free
()¶
Public Static Attributes
-
const size_t
EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD
= static_cast<size_t>(Traits::EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD)¶
-
const size_t
EXPLICIT_INITIAL_INDEX_SIZE
= static_cast<size_t>(Traits::EXPLICIT_INITIAL_INDEX_SIZE)¶
-
const size_t
IMPLICIT_INITIAL_INDEX_SIZE
= static_cast<size_t>(Traits::IMPLICIT_INITIAL_INDEX_SIZE)¶
-
const size_t
INITIAL_IMPLICIT_PRODUCER_HASH_SIZE
= static_cast<size_t>(Traits::INITIAL_IMPLICIT_PRODUCER_HASH_SIZE)¶
-
const std::uint32_t
EXPLICIT_CONSUMER_CONSUMPTION_QUOTA_BEFORE_ROTATE
= static_cast<std::uint32_t>(Traits::EXPLICIT_CONSUMER_CONSUMPTION_QUOTA_BEFORE_ROTATE)¶
-
const size_t hpx::concurrency::ConcurrentQueue::MAX_SUBQUEUE_SIZE = (details::const_numeric_max<size_t>::value - static_cast<size_t>(Traits::MAX_SUBQUEUE_SIZE) < BLOCK_SIZE) ? details::const_numeric_max<size_t>::value : ((static_cast<size_t>(Traits::MAX_SUBQUEUE_SIZE) + (BLOCK_SIZE - 1)) / BLOCK_SIZE * BLOCK_SIZE)
Private Types
Private Functions
-
ConcurrentQueue &
swap_internal
(ConcurrentQueue &other)¶
-
template<AllocationMode
canAlloc
, typenameU
>
boolinner_enqueue
(producer_token_t const &token, U &&element)¶
-
template<AllocationMode
canAlloc
, typenameU
>
boolinner_enqueue
(U &&element)¶
-
template<AllocationMode
canAlloc
, typenameIt
>
boolinner_enqueue_bulk
(producer_token_t const &token, It itemFirst, size_t count)¶
-
template<AllocationMode
canAlloc
, typenameIt
>
boolinner_enqueue_bulk
(It itemFirst, size_t count)¶
-
bool
update_current_producer_after_rotation
(consumer_token_t &token)¶
-
template<AllocationMode
canAlloc
>
Block *requisition_block
()¶
-
ProducerBase *
recycle_or_create_producer
(bool isExplicit)¶
-
ProducerBase *
recycle_or_create_producer
(bool isExplicit, bool &recycled)¶
-
ProducerBase *
add_producer
(ProducerBase *producer)¶
-
void
reown_producers
()¶
-
void
populate_initial_implicit_producer_hash
()¶
-
void
swap_implicit_producer_hashes
(ConcurrentQueue &other)¶
-
ImplicitProducer *
get_or_add_implicit_producer
()¶
Private Members
-
std::atomic<ProducerBase*>
producerListTail
¶
-
std::atomic<ImplicitProducerHash*>
implicitProducerHash
¶
-
ImplicitProducerHash
initialImplicitProducerHash
¶
-
std::array<ImplicitProducerKVP, INITIAL_IMPLICIT_PRODUCER_HASH_SIZE>
initialImplicitProducerHashEntries
¶
Private Static Functions
Friends
-
friend
hpx::concurrency::ProducerToken
-
friend
hpx::concurrency::ConsumerToken
-
friend
hpx::concurrency::ExplicitProducer
-
friend
hpx::concurrency::ImplicitProducer
-
friend
hpx::concurrency::ConcurrentQueueTests
-
struct
Block
¶ Public Functions
-
template<>
Block
()¶
-
template<InnerQueueContext
context
>
boolis_empty
() const¶
-
template<InnerQueueContext
context
>
boolset_empty
(index_t i)¶
-
template<InnerQueueContext
context
>
boolset_many_empty
(index_t i, size_t count)¶
-
template<InnerQueueContext
context
>
voidset_all_empty
()¶
-
template<InnerQueueContext
context
>
voidreset_empty
()¶
-
template<>
T *operator[]
(index_t idx)¶
-
template<>
T const *operator[]
(index_t idx) const¶
Public Members
-
template<>
charelements
[sizeof(T) *BLOCK_SIZE
]¶
-
template<>
details::max_align_tdummy
¶
-
template<>
Block *next
¶
-
std::atomic<bool> hpx::concurrency::ConcurrentQueue< T, Traits >::Block::emptyFlags[BLOCK_SIZE<=EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD ? BLOCK_SIZE :1]
-
template<>
booldynamicallyAllocated
¶
Private Members
-
template<>
union hpx::concurrency::ConcurrentQueue::Block::[anonymous] [anonymous]¶
-
template<>
-
struct
ExplicitProducer
: public hpx::concurrency::ConcurrentQueue<T, Traits>::ProducerBase¶ Public Functions
-
template<>
ExplicitProducer
(ConcurrentQueue *parent)¶
-
template<>
~ExplicitProducer
()¶
-
template<AllocationMode
allocMode
, typenameU
>
boolenqueue
(U &&element)¶
-
template<typename
U
>
booldequeue
(U &element)¶
-
template<AllocationMode
allocMode
, typenameIt
>
boolenqueue_bulk
(It itemFirst, size_t count)¶
-
template<typename
It
>
size_tdequeue_bulk
(It &itemFirst, size_t max)¶
Private Functions
-
template<>
boolnew_block_index
(size_t numberOfFilledSlotsToExpose)¶
Private Members
-
template<>
size_tpr_blockIndexSlotsUsed
¶
-
template<>
size_tpr_blockIndexSize
¶
-
template<>
size_tpr_blockIndexFront
¶
-
template<>
BlockIndexEntry *pr_blockIndexEntries
¶
-
template<>
void *pr_blockIndexRaw
¶
-
struct
BlockIndexEntry
¶
-
struct
BlockIndexHeader
¶
-
template<>
-
template<typename
N
>
structFreeList
¶ Public Functions
-
template<>
FreeList
()¶
-
template<>
voidswap
(FreeList &other)¶
-
template<>
FreeList &operator=
(FreeList const&)¶
-
template<>
voidadd
(N *node)¶
-
template<>
N *try_get
()¶
-
template<>
N *head_unsafe
() const¶
Private Functions
-
template<>
voidadd_knowing_refcount_is_zero
(N *node)¶
-
template<>
-
struct
ImplicitProducer
: public hpx::concurrency::ConcurrentQueue<T, Traits>::ProducerBase¶ Public Functions
-
template<>
ImplicitProducer
(ConcurrentQueue *parent)¶
-
template<>
~ImplicitProducer
()¶
-
template<AllocationMode
allocMode
, typenameU
>
boolenqueue
(U &&element)¶
-
template<typename
U
>
booldequeue
(U &element)¶
-
template<AllocationMode
allocMode
, typenameIt
>
boolenqueue_bulk
(It itemFirst, size_t count)¶
-
template<typename
It
>
size_tdequeue_bulk
(It &itemFirst, size_t max)¶
Private Functions
-
template<AllocationMode
allocMode
>
boolinsert_block_index_entry
(BlockIndexEntry *&idxEntry, index_t blockStartIndex)¶
-
template<>
voidrewind_block_index_tail
()¶
-
template<>
BlockIndexEntry *get_block_index_entry_for_index
(index_t index) const¶
-
template<>
size_tget_block_index_index_for_index
(index_t index, BlockIndexHeader *&localBlockIndex) const¶
-
template<>
boolnew_block_index
()¶
Private Members
-
template<>
size_tnextBlockIndexCapacity
¶
Private Static Attributes
-
template<>
const index_tINVALID_BLOCK_BASE
= 1¶
-
struct
BlockIndexEntry
¶
-
struct
BlockIndexHeader
¶
-
template<>
-
struct
ImplicitProducerHash
¶
-
struct
ImplicitProducerKVP
¶ Public Functions
-
template<>
ImplicitProducerKVP
()¶
-
template<>
ImplicitProducerKVP
(ImplicitProducerKVP &&other)¶
-
template<>
ImplicitProducerKVP &operator=
(ImplicitProducerKVP &&other)¶
-
template<>
voidswap
(ImplicitProducerKVP &other)¶
-
template<>
-
struct
ProducerBase
: public hpx::concurrency::details::ConcurrentQueueProducerTypelessBase¶ Public Functions
-
template<>
ProducerBase
(ConcurrentQueue *parent_, bool isExplicit_)¶
-
template<>
virtual~ProducerBase
()¶
-
template<typename
U
>
booldequeue
(U &element)¶
-
template<typename
It
>
size_tdequeue_bulk
(It &itemFirst, size_t max)¶
-
template<>
ProducerBase *next_prod
() const¶
-
template<>
size_tsize_approx
() const¶
-
template<>
index_tgetTail
() const¶
-
template<>
-
typedef ::hpx::concurrency::ProducerToken
-
struct
ConcurrentQueueDefaultTraits
¶ -
Public Static Attributes
-
const size_t
MAX_SUBQUEUE_SIZE
= details::const_numeric_max<size_t>::value¶
-
const size_t
-
struct
ConsumerToken
¶ Public Functions
-
ConsumerToken
(ConsumerToken &&other)¶
-
ConsumerToken &
operator=
(ConsumerToken &&other)¶
-
void
swap
(ConsumerToken &other)¶
-
ConsumerToken
(ConsumerToken const&)¶
-
ConsumerToken &
operator=
(ConsumerToken const&)¶
Private Members
-
details::ConcurrentQueueProducerTypelessBase *
currentProducer
¶
-
details::ConcurrentQueueProducerTypelessBase *
desiredProducer
¶
Friends
-
friend
hpx::concurrency::ConcurrentQueue
-
friend
hpx::concurrency::ConcurrentQueueTests
-
-
struct
ProducerToken
¶ Public Functions
-
ProducerToken
(ProducerToken &&other)¶
-
ProducerToken &
operator=
(ProducerToken &&other)¶
-
void
swap
(ProducerToken &other)¶
-
bool
valid
() const¶
-
~ProducerToken
()¶
-
ProducerToken
(ProducerToken const&)¶
-
ProducerToken &
operator=
(ProducerToken const&)¶
Protected Attributes
-
details::ConcurrentQueueProducerTypelessBase *
producer
¶
Friends
-
friend
hpx::concurrency::ConcurrentQueue
-
friend
hpx::concurrency::ConcurrentQueueTests
-
-
namespace
details
¶ -
Functions
-
static thread_id_t
thread_id
()¶
-
static bool() hpx::concurrency::details::likely(bool x)
-
static bool() hpx::concurrency::details::unlikely(bool x)
-
static size_t
hash_thread_id
(thread_id_t id)¶
-
template<typename
U
>
static char *align_for
(char *ptr)¶
-
template<bool
use32
>
struct_hash_32_or_64
¶
-
template<>
struct_hash_32_or_64
<1>¶
-
struct
ConcurrentQueueProducerTypelessBase
¶ Public Functions
-
ConcurrentQueueProducerTypelessBase
()¶
Public Members
-
ProducerToken *
token
¶
-
-
template<typename
T
>
structconst_numeric_max
¶ Public Static Attributes
-
const T hpx::concurrency::details::const_numeric_max::value= std::numeric_limits<T>::is_signed ? (static_cast<T>(1) << (sizeof(T) * CHAR_BIT - 1)) - static_cast<T>(1) : static_cast<T>(-1)
-
-
union
max_align_t
¶
-
template<bool
Enable
>
structnomove_if
¶
-
template<>
structnomove_if
<false>¶
-
template<>
structstatic_is_lock_free
<bool>¶
-
template<typename
U
>
structstatic_is_lock_free
<U*>¶ Public Types
-
enum [anonymous]¶
Values:
-
value
= ATOMIC_POINTER_LOCK_FREE
-
-
enum [anonymous]¶
-
template<typename
T
>
structstatic_is_lock_free_num
¶ Public Types
-
enum [anonymous]¶
Values:
-
value
= 0
-
-
enum [anonymous]¶
-
template<>
structstatic_is_lock_free_num
<int>¶ Public Types
-
enum [anonymous]¶
Values:
-
value
= ATOMIC_INT_LOCK_FREE
-
-
enum [anonymous]¶
-
template<>
structstatic_is_lock_free_num
<long>¶ Public Types
-
enum [anonymous]¶
Values:
-
value
= ATOMIC_LONG_LOCK_FREE
-
-
enum [anonymous]¶
-
template<>
structstatic_is_lock_free_num
<long long>¶ Public Types
-
enum [anonymous]¶
Values:
-
value
= ATOMIC_LLONG_LOCK_FREE
-
-
enum [anonymous]¶
-
template<>
structstatic_is_lock_free_num
<short>¶ Public Types
-
enum [anonymous]¶
Values:
-
value
= ATOMIC_SHORT_LOCK_FREE
-
-
enum [anonymous]¶
-
template<>
structstatic_is_lock_free_num
<signed char>¶ Public Types
-
enum [anonymous]¶
Values:
-
value
= ATOMIC_CHAR_LOCK_FREE
-
-
enum [anonymous]¶
-
template<typename
thread_id_t
>
structthread_id_converter
¶ -
Public Static Functions
-
static thread_id_hash_t
prehash
(thread_id_t const &x)¶
-
static thread_id_hash_t
-
static thread_id_t
-
template<typename
-
namespace
-
namespace
boost
¶ -
namespace
lockfree
¶ -
-
template<typename
T
, typenamefreelist_t
= caching_freelist_t, typenameAlloc
= std::allocator<T>>
structdeque
¶ Public Types
-
template<>
usingnode
= deque_node<T>¶
-
template<>
usinganchor
= deque_anchor<T>¶
-
template<>
usingnode_allocator
= typename std::allocator_traits<Alloc>::template rebind_alloc<node>¶
-
template<>
usingpool
= typename std::conditional<std::is_same<freelist_t, caching_freelist_t>::value, caching_freelist<node, node_allocator>, static_freelist<node, node_allocator>>::type¶
Public Functions
-
HPX_NON_COPYABLE
(deque)¶
-
~deque
()¶
-
bool
empty
() const¶
-
bool
is_lock_free
() const¶
-
bool
push_left
(T const &data)¶
-
bool
push_right
(T const &data)¶
-
bool
pop_left
(T &r)¶
-
bool
pop_left
(T *r)¶
-
bool
pop_right
(T &r)¶
-
bool
pop_right
(T *r)¶
-
template<>
-
template<typename
T
>
structdeque_anchor
¶ -
Public Functions
-
deque_anchor
()¶
-
deque_anchor
(deque_anchor const &p)¶
-
deque_anchor
(pair const &p)¶
-
pair
lrs
() volatile const¶
-
node *
left
() volatile const¶
-
node *
right
() volatile const¶
-
tag_t
status
() volatile const¶
-
tag_t
tag
() volatile const¶
-
bool
cas
(deque_anchor &expected, deque_anchor const &desired) volatile¶
-
bool
cas
(pair &expected, deque_anchor const &desired) volatile¶
-
bool
cas
(deque_anchor &expected, pair const &desired) volatile¶
-
bool
cas
(pair &expected, pair const &desired) volatile¶
-
bool
operator==
(volatile deque_anchor const &rhs) const¶
-
bool
operator!=
(volatile deque_anchor const &rhs) const¶
-
bool
operator==
(volatile pair const &rhs) const¶
-
bool
operator!=
(volatile pair const &rhs) const¶
-
bool
is_lock_free
() const¶
Private Members
-
atomic_pair
pair_
¶
-
-
template<typename
T
>
structdeque_node
¶ Public Types
-
typedef detail::tagged_ptr<deque_node>
pointer
¶
Public Functions
-
deque_node
()¶
-
deque_node
(deque_node const &p)¶
-
deque_node
(deque_node *lptr, deque_node *rptr, T const &v, tag_t ltag = 0, tag_t rtag = 0)¶
-
typedef detail::tagged_ptr<deque_node>
-
template<typename
-
namespace
-
namespace
hpx