Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
#include <concurrent_monitor.h>
Classes | |
class | thread_context |
Public Member Functions | |
concurrent_monitor () | |
ctor More... | |
~concurrent_monitor () | |
dtor More... | |
void | prepare_wait (thread_context &thr, uintptr_t ctx=0) |
prepare wait by inserting 'thr' into the wait queue More... | |
bool | commit_wait (thread_context &thr) |
Commit wait if event count has not changed; otherwise, cancel wait. More... | |
void | cancel_wait (thread_context &thr) |
Cancel the wait. Removes the thread from the wait queue if not removed yet. More... | |
template<typename WaitUntil , typename Context > | |
void | wait (WaitUntil until, Context on) |
Wait for a condition to be satisfied with waiting-on context. More... | |
void | notify_one () |
Notify one thread about the event. More... | |
void | notify_one_relaxed () |
Notify one thread about the event. Relaxed version. More... | |
void | notify_all () |
Notify all waiting threads of the event. More... | |
void | notify_all_relaxed () |
Notify all waiting threads of the event; Relaxed version. More... | |
template<typename P > | |
void | notify (const P &predicate) |
Notify waiting threads of the event that satisfies the given predicate. More... | |
template<typename P > | |
void | notify_relaxed (const P &predicate) |
Notify waiting threads of the event that satisfies the given predicate; Relaxed version. More... | |
void | abort_all () |
Abort any sleeping threads at the time of the call. More... | |
void | abort_all_relaxed () |
Abort any sleeping threads at the time of the call; Relaxed version. More... | |
Private Member Functions | |
thread_context * | to_thread_context (waitset_node_t *n) |
![]() | |
no_copy (const no_copy &)=delete | |
no_copy ()=default | |
Private Attributes | |
tbb::spin_mutex | mutex_ec |
waitset_t | waitset_ec |
__TBB_atomic unsigned | epoch |
fine-grained concurrent_monitor implementation
Definition at line 93 of file concurrent_monitor.h.
|
inline |
ctor
Definition at line 125 of file concurrent_monitor.h.
References tbb::internal::__TBB_store_relaxed(), and epoch.
tbb::internal::concurrent_monitor::~concurrent_monitor | ( | ) |
dtor
Definition at line 27 of file concurrent_monitor.cpp.
References __TBB_ASSERT, abort_all(), tbb::internal::circular_doubly_linked_list_with_sentinel::empty(), and waitset_ec.
|
inline |
Abort any sleeping threads at the time of the call.
Definition at line 175 of file concurrent_monitor.h.
References abort_all_relaxed(), and tbb::atomic_fence().
Referenced by tbb::internal::concurrent_queue_base_v3::internal_abort(), and ~concurrent_monitor().
void tbb::internal::concurrent_monitor::abort_all_relaxed | ( | ) |
Abort any sleeping threads at the time of the call; Relaxed version.
Definition at line 107 of file concurrent_monitor.cpp.
References tbb::internal::__TBB_load_relaxed(), tbb::internal::__TBB_store_relaxed(), tbb::internal::concurrent_monitor::thread_context::aborted, tbb::internal::circular_doubly_linked_list_with_sentinel::clear(), tbb::internal::circular_doubly_linked_list_with_sentinel::empty(), tbb::internal::circular_doubly_linked_list_with_sentinel::end(), end, epoch, tbb::internal::circular_doubly_linked_list_with_sentinel::flush_to(), tbb::internal::circular_doubly_linked_list_with_sentinel::front(), tbb::internal::concurrent_monitor::thread_context::in_waitset, mutex_ec, tbb::internal::circular_doubly_linked_list_with_sentinel::node_t::next, tbb::internal::concurrent_monitor::thread_context::semaphore(), to_thread_context(), tbb::internal::binary_semaphore::V(), and waitset_ec.
Referenced by abort_all().
void tbb::internal::concurrent_monitor::cancel_wait | ( | thread_context & | thr | ) |
Cancel the wait. Removes the thread from the wait queue if not removed yet.
Definition at line 50 of file concurrent_monitor.cpp.
References tbb::internal::concurrent_monitor::thread_context::in_waitset, mutex_ec, tbb::internal::circular_doubly_linked_list_with_sentinel::remove(), tbb::internal::concurrent_monitor::thread_context::skipped_wakeup, and waitset_ec.
Referenced by commit_wait(), tbb::internal::concurrent_queue_base_v3::internal_insert_item(), tbb::internal::concurrent_queue_base_v3::internal_pop(), and wait().
|
inline |
Commit wait if event count has not changed; otherwise, cancel wait.
Returns true if committed, false if canceled.
Definition at line 135 of file concurrent_monitor.h.
References __TBB_ASSERT, tbb::internal::__TBB_load_relaxed(), tbb::internal::concurrent_monitor::thread_context::aborted, cancel_wait(), tbb::internal::eid_user_abort, tbb::internal::concurrent_monitor::thread_context::epoch, epoch, tbb::internal::concurrent_monitor::thread_context::in_waitset, tbb::internal::binary_semaphore::P(), tbb::internal::concurrent_monitor::thread_context::ready, tbb::internal::concurrent_monitor::thread_context::semaphore(), and tbb::internal::throw_exception().
Referenced by tbb::internal::concurrent_queue_base_v3::internal_insert_item(), tbb::internal::concurrent_queue_base_v3::internal_pop(), and wait().
|
inline |
Notify waiting threads of the event that satisfies the given predicate.
Definition at line 169 of file concurrent_monitor.h.
References tbb::atomic_fence(), and notify_relaxed().
Referenced by tbb::internal::concurrent_queue_base_v3::internal_insert_if_not_full(), tbb::internal::concurrent_queue_base_v3::internal_insert_item(), tbb::internal::concurrent_queue_base_v3::internal_pop(), and tbb::internal::concurrent_queue_base_v3::internal_pop_if_present().
|
inline |
Notify all waiting threads of the event.
Definition at line 163 of file concurrent_monitor.h.
References tbb::atomic_fence(), and notify_all_relaxed().
void tbb::internal::concurrent_monitor::notify_all_relaxed | ( | ) |
Notify all waiting threads of the event; Relaxed version.
Definition at line 84 of file concurrent_monitor.cpp.
References tbb::internal::__TBB_load_relaxed(), tbb::internal::__TBB_store_relaxed(), tbb::internal::circular_doubly_linked_list_with_sentinel::clear(), tbb::internal::circular_doubly_linked_list_with_sentinel::empty(), tbb::internal::circular_doubly_linked_list_with_sentinel::end(), end, epoch, tbb::internal::circular_doubly_linked_list_with_sentinel::flush_to(), tbb::internal::circular_doubly_linked_list_with_sentinel::front(), tbb::internal::concurrent_monitor::thread_context::in_waitset, mutex_ec, tbb::internal::circular_doubly_linked_list_with_sentinel::node_t::next, tbb::internal::concurrent_monitor::thread_context::semaphore(), to_thread_context(), tbb::internal::binary_semaphore::V(), and waitset_ec.
Referenced by notify_all().
|
inline |
Notify one thread about the event.
Definition at line 157 of file concurrent_monitor.h.
References tbb::atomic_fence(), and notify_one_relaxed().
Referenced by tbb::internal::generic_scheduler::nested_arena_exit().
void tbb::internal::concurrent_monitor::notify_one_relaxed | ( | ) |
Notify one thread about the event. Relaxed version.
Definition at line 66 of file concurrent_monitor.cpp.
References tbb::internal::__TBB_load_relaxed(), tbb::internal::__TBB_store_relaxed(), tbb::internal::circular_doubly_linked_list_with_sentinel::empty(), tbb::internal::circular_doubly_linked_list_with_sentinel::end(), end, epoch, tbb::internal::circular_doubly_linked_list_with_sentinel::front(), tbb::internal::concurrent_monitor::thread_context::in_waitset, mutex_ec, tbb::internal::circular_doubly_linked_list_with_sentinel::remove(), tbb::internal::concurrent_monitor::thread_context::semaphore(), to_thread_context(), tbb::internal::binary_semaphore::V(), and waitset_ec.
Referenced by notify_one().
void tbb::internal::concurrent_monitor::notify_relaxed | ( | const P & | predicate | ) |
Notify waiting threads of the event that satisfies the given predicate; Relaxed version.
Definition at line 204 of file concurrent_monitor.h.
References tbb::internal::__TBB_load_relaxed(), tbb::internal::__TBB_store_relaxed(), tbb::internal::circular_doubly_linked_list_with_sentinel::add(), tbb::internal::circular_doubly_linked_list_with_sentinel::clear(), tbb::internal::concurrent_monitor::thread_context::context, tbb::internal::circular_doubly_linked_list_with_sentinel::empty(), tbb::internal::circular_doubly_linked_list_with_sentinel::end(), end, epoch, tbb::internal::circular_doubly_linked_list_with_sentinel::front(), tbb::internal::concurrent_monitor::thread_context::in_waitset, tbb::internal::circular_doubly_linked_list_with_sentinel::last(), mutex_ec, tbb::internal::circular_doubly_linked_list_with_sentinel::node_t::next, tbb::internal::circular_doubly_linked_list_with_sentinel::node_t::prev, tbb::internal::circular_doubly_linked_list_with_sentinel::remove(), tbb::internal::concurrent_monitor::thread_context::semaphore(), to_thread_context(), tbb::internal::binary_semaphore::V(), and waitset_ec.
Referenced by notify().
void tbb::internal::concurrent_monitor::prepare_wait | ( | thread_context & | thr, |
uintptr_t | ctx = 0 |
||
) |
prepare wait by inserting 'thr' into the wait queue
Definition at line 32 of file concurrent_monitor.cpp.
References tbb::internal::__TBB_load_relaxed(), tbb::internal::__TBB_store_relaxed(), tbb::internal::circular_doubly_linked_list_with_sentinel::add(), tbb::atomic_fence(), tbb::internal::concurrent_monitor::thread_context::context, tbb::internal::concurrent_monitor::thread_context::epoch, epoch, tbb::internal::concurrent_monitor::thread_context::in_waitset, mutex_ec, tbb::internal::binary_semaphore::P(), tbb::internal::concurrent_monitor::thread_context::ready, tbb::internal::concurrent_monitor::thread_context::semaphore(), tbb::internal::concurrent_monitor::thread_context::skipped_wakeup, and waitset_ec.
Referenced by tbb::internal::concurrent_queue_base_v3::internal_insert_item(), tbb::internal::concurrent_queue_base_v3::internal_pop(), and wait().
|
inlineprivate |
Definition at line 184 of file concurrent_monitor.h.
Referenced by abort_all_relaxed(), notify_all_relaxed(), notify_one_relaxed(), and notify_relaxed().
void tbb::internal::concurrent_monitor::wait | ( | WaitUntil | until, |
Context | on | ||
) |
Wait for a condition to be satisfied with waiting-on context.
Definition at line 188 of file concurrent_monitor.h.
References cancel_wait(), commit_wait(), and prepare_wait().
|
private |
Definition at line 183 of file concurrent_monitor.h.
Referenced by abort_all_relaxed(), commit_wait(), concurrent_monitor(), notify_all_relaxed(), notify_one_relaxed(), notify_relaxed(), and prepare_wait().
|
private |
Definition at line 181 of file concurrent_monitor.h.
Referenced by abort_all_relaxed(), cancel_wait(), notify_all_relaxed(), notify_one_relaxed(), notify_relaxed(), and prepare_wait().
|
private |
Definition at line 182 of file concurrent_monitor.h.
Referenced by abort_all_relaxed(), cancel_wait(), notify_all_relaxed(), notify_one_relaxed(), notify_relaxed(), prepare_wait(), and ~concurrent_monitor().