projects
/
libcds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
07c2c73
)
Fixed TSan annotation
author
khizmax
<khizmax@gmail.com>
Tue, 29 Nov 2016 14:56:22 +0000
(17:56 +0300)
committer
khizmax
<khizmax@gmail.com>
Tue, 29 Nov 2016 14:56:22 +0000
(17:56 +0300)
cds/sync/spinlock.h
patch
|
blob
|
history
diff --git
a/cds/sync/spinlock.h
b/cds/sync/spinlock.h
index 32b75ea17831cb66412b8f481f63695d3ace230c..b1d952781261efc507ae6a2a6d66ff5fa8939cb7 100644
(file)
--- a/
cds/sync/spinlock.h
+++ b/
cds/sync/spinlock.h
@@
-130,7
+130,14
@@
namespace cds {
bool try_lock() CDS_NOEXCEPT
{
bool bCurrent = false;
bool try_lock() CDS_NOEXCEPT
{
bool bCurrent = false;
+
+# ifdef CDS_THREAD_SANITIZER_ENABLED
+ if ( m_spin.compare_exchange_strong( bCurrent, true, atomics::memory_order_acquire, atomics::memory_order_relaxed )) {
+ CDS_TSAN_ANNOTATE_MUTEX_ACQUIRED( &m_spin );
+ }
+# else
m_spin.compare_exchange_strong( bCurrent, true, atomics::memory_order_acquire, atomics::memory_order_relaxed );
m_spin.compare_exchange_strong( bCurrent, true, atomics::memory_order_acquire, atomics::memory_order_relaxed );
+# endif
CDS_DEBUG_ONLY(
if ( !bCurrent ) {
CDS_DEBUG_ONLY(
if ( !bCurrent ) {
@@
-149,10
+156,8
@@
namespace cds {
{
backoff_strategy backoff;
while ( nTryCount-- ) {
{
backoff_strategy backoff;
while ( nTryCount-- ) {
- if ( try_lock() ) {
- CDS_TSAN_ANNOTATE_MUTEX_ACQUIRED( &m_spin );
+ if ( try_lock() )
return true;
return true;
- }
backoff();
}
return false;
backoff();
}
return false;
@@
-241,7
+246,15
@@
namespace cds {
bool try_acquire() CDS_NOEXCEPT
{
integral_type nCurrent = 0;
bool try_acquire() CDS_NOEXCEPT
{
integral_type nCurrent = 0;
+# ifdef CDS_THREAD_SANITIZER_ENABLED
+ if ( m_spin.compare_exchange_weak( nCurrent, 1, atomics::memory_order_acquire, atomics::memory_order_relaxed )) {
+ CDS_TSAN_ANNOTATE_MUTEX_ACQUIRED( &m_spin );
+ return true;
+ }
+ return false;
+# else
return m_spin.compare_exchange_weak( nCurrent, 1, atomics::memory_order_acquire, atomics::memory_order_relaxed );
return m_spin.compare_exchange_weak( nCurrent, 1, atomics::memory_order_acquire, atomics::memory_order_relaxed );
+# endif
}
bool try_acquire( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()()))
}
bool try_acquire( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()()))
@@
-249,10
+262,8
@@
namespace cds {
backoff_strategy bkoff;
while ( nTryCount-- ) {
backoff_strategy bkoff;
while ( nTryCount-- ) {
- if ( try_acquire() ) {
- CDS_TSAN_ANNOTATE_MUTEX_ACQUIRED( &m_spin );
+ if ( try_acquire() )
return true;
return true;
- }
bkoff();
}
return false;
bkoff();
}
return false;