17 #ifndef __TBB_concurrent_monitor_H 18 #define __TBB_concurrent_monitor_H 38 explicit node_t() : next((
node_t*)(uintptr_t)0xcdcdcdcd), prev((
node_t*)(uintptr_t)0xcdcdcdcd) {}
66 n.prev->next = n.next;
67 n.next->prev = n.prev;
99 thread_context() : skipped_wakeup(false), aborted(false), ready(false), context(0) {
115 tbb::aligned_space<binary_semaphore>
sema;
153 template<
typename WaitUntil,
typename Context>
154 void wait( WaitUntil until, Context on );
160 void notify_one_relaxed();
166 void notify_all_relaxed();
169 template<
typename P>
void notify(
const P& predicate ) {
atomic_fence(); notify_relaxed( predicate );}
172 template<
typename P>
void notify_relaxed(
const P& predicate );
178 void abort_all_relaxed();
187 template<
typename WaitUntil,
typename Context>
192 prepare_wait( thr_ctx, on() );
194 if( (slept = commit_wait( thr_ctx ) )==
true )
197 prepare_wait( thr_ctx, on() );
200 cancel_wait( thr_ctx );
205 if( waitset_ec.empty() )
209 const waitset_node_t*
end = waitset_ec.end();
213 for( waitset_node_t* n=waitset_ec.last(); n!=
end; n=nxt ) {
216 if( predicate( thr->
context ) ) {
217 waitset_ec.remove( *n );
225 for( waitset_node_t* n=temp.
front(); n!=
end; n=nxt ) {
227 to_thread_context(n)->semaphore().V();
void __TBB_store_relaxed(volatile T &location, V value)
Represents acquisition of a mutex.
Edsger Dijkstra's counting semaphore.
circular_doubly_linked_list_with_sentinel::node_t waitset_node_t
void notify_one()
Notify one thread about the event.
bool commit_wait(thread_context &thr)
Commit wait if event count has not changed; otherwise, cancel wait.
__TBB_atomic unsigned epoch
thread_context * to_thread_context(waitset_node_t *n)
binary_semaphore & semaphore()
A lock that occupies a single byte.
void add(node_t *n)
add to the back of the list
__TBB_atomic size_t count
tbb::aligned_space< binary_semaphore > sema
void abort_all()
Abort any sleeping threads at the time of the call.
tbb::atomic< bool > in_waitset
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
void flush_to(circular_doubly_linked_list_with_sentinel &lst)
move all elements to 'lst' and initialize the 'this' list
Base class for types that should not be copied or assigned.
circular_doubly_linked_list_with_sentinel()
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void notify_relaxed(const P &predicate)
Notify waiting threads of the event that satisfies the given predicate; Relaxed version.
T __TBB_load_relaxed(const volatile T &location)
void wait(WaitUntil until, Context on)
Wait for a condition to be satisfied with waiting-on context.
binary_semaphore for concurrent monitor
Circular doubly-linked list with sentinel.
const node_t * end() const
__TBB_atomic unsigned epoch
void notify(const P &predicate)
Notify waiting threads of the event that satisfies the given predicate.
void atomic_fence()
Sequentially consistent full memory fence.
~circular_doubly_linked_list_with_sentinel()
circular_doubly_linked_list_with_sentinel waitset_t
#define __TBB_NOINLINE(decl)
void notify_all()
Notify all waiting threads of the event.