22 #if defined(_MSC_VER) && defined(_Wp64)
24 #pragma warning (disable: 4244)
28 namespace interface5 {
39 uintptr_t old = operand;
40 uintptr_t result = operand.compare_and_swap(old|value, old);
41 if (result==old)
return result;
48 uintptr_t old = operand;
49 uintptr_t result = operand.compare_and_swap(old&value, old);
50 if (result==old)
return result;
56 template<
typename T,
typename U>
59 while( location>=value ) backoff.
pause();
64 template<
typename T,
typename U>
67 while( !(location & value) ) backoff.
pause();
77 #if TBB_USE_THREADING_TOOLS
122 if ((pred =
writer_tail.compare_and_swap(I, NULL)) != NULL) {
253 __TBB_ASSERT(a_writer_lock !=
writer_head,
"Internal error: About to turn writer_head into dangling reference.");
254 delete a_writer_lock;
297 if (mutex->is_current_writer()) {
302 (
void) mutex->start_write(
this);
315 if (mutex->is_current_writer()) {
320 mutex->start_read(
this);
330 __TBB_ASSERT(mutex->is_current_writer(),
"~scoped_lock() destroyed by thread different than thread that holds lock.");
331 mutex->end_write(
this);
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
uintptr_t fetch_and_and(atomic< uintptr_t > &operand, uintptr_t value)
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
tbb_thread::id my_current_writer
Writer that owns the mutex; tbb_thread::id() otherwise.
atomic< scoped_lock * > writer_head
The list of pending writers.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
scoped_lock_read * next
The next queued competitor for the mutex.
bool start_write(scoped_lock *)
Attempts to acquire write lock.
void set_next_writer(scoped_lock *w)
Sets writer_head to w and attempts to unblock.
The scoped lock pattern for write locks.
#define ITT_NOTIFY(name, obj)
#define _T(string_literal)
Standard Windows style macro to markup the string literals.
void pause()
Pause for a while.
bool is_current_writer()
Checks if current thread holds write lock.
void end_read()
Relinquishes read lock by decrementing counter; last reader wakes pending writer. ...
atomic< status_t > status
Status flag of the thread associated with this node.
#define ITT_SYNC_CREATE(obj, type, name)
reader_writer_lock()
Constructs a new reader_writer_lock.
scoped_lock * next
The next queued competitor for the mutex.
void start_read(scoped_lock_read *)
Attempts to acquire read lock.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id head
void __TBB_EXPORTED_METHOD internal_construct()
All checks from mutex constructor using mutex.state were moved here.
void __TBB_EXPORTED_METHOD internal_destroy()
All checks from mutex destructor using mutex.state were moved here.
void __TBB_EXPORTED_METHOD lock_read()
Acquires the reader_writer_lock for read.
The scoped lock pattern for read locks.
void __TBB_AtomicOR(volatile void *operand, uintptr_t addend)
atomic< status_t > status
Status flag of the thread associated with this node.
atomic< uintptr_t > rdr_count_and_flags
Status of mutex.
atomic< scoped_lock * > writer_tail
The last node in the list of pending writers.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p sync_releasing
__TBB_DEPRECATED_IN_VERBOSE_MODE tbb_thread::id get_id()
atomic< scoped_lock_read * > reader_head
The list of pending readers.
uintptr_t fetch_and_or(atomic< uintptr_t > &operand, uintptr_t value)
bool try_lock()
Try acquiring lock (non-blocking)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
void __TBB_EXPORTED_METHOD lock()
Acquires the reader_writer_lock for write.
The scoped locking pattern.
void spin_wait_while_geq(const volatile T &location, U value)
Spin WHILE the value at the location is greater than or equal to a given value.
void unblock_readers()
Unblocks pending readers.
void end_write(scoped_lock *)
Relinquishes write lock to next waiting writer or group of readers.
void unlock()
Release lock.
bool __TBB_EXPORTED_METHOD try_lock_read()
Tries to acquire the reader_writer_lock for read.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id id
Class that implements exponential backoff.
void spin_wait_until_and(const volatile T &location, U value)
Spin UNTIL (location & value) is true.
class friend class("tbb::reader_writer_lock is deprecated, use std::shared_mutex") reader_writer_lock scoped_lock_read
Writer-preference reader-writer lock with local-only spinning on readers.