Removed trailing spaces
[libcds.git] / cds / sync / spinlock.h
index 1708bba0c4abc8f2a37b5209877cdc943d8495cb..0241cd8d004533275c054acb33983ae8f148c6a8 100644 (file)
@@ -1,7 +1,7 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
@@ -76,12 +76,11 @@ namespace cds {
         public:
             /// Construct free (unlocked) spin-lock
             spin_lock() CDS_NOEXCEPT
+                : m_spin( false )
 #    ifdef CDS_DEBUG
-                :m_dbgOwnerId( OS::c_NullThreadId )
+                m_dbgOwnerId( OS::c_NullThreadId )
 #    endif
-            {
-                m_spin.store( false, atomics::memory_order_relaxed );
-            }
+            {}
 
             /// Construct spin-lock in specified state
             /**
@@ -130,7 +129,8 @@ namespace cds {
             bool try_lock() CDS_NOEXCEPT
             {
                 bool bCurrent = false;
-                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_acquire );
 
                 CDS_DEBUG_ONLY(
                     if ( !bCurrent ) {
@@ -145,7 +145,7 @@ namespace cds {
                 Returns \p true if locking is succeeded
                 otherwise (if the spin is already locked) returns \p false
             */
-            bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()()) )
+            bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()()))
             {
                 backoff_strategy backoff;
                 while ( nTryCount-- ) {
@@ -238,7 +238,7 @@ namespace cds {
             bool try_acquire() CDS_NOEXCEPT
             {
                 integral_type nCurrent = 0;
-                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_acquire );
             }
 
             bool try_acquire( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()()))
@@ -282,7 +282,7 @@ namespace cds {
                 , m_OwnerId( OS::c_NullThreadId )
             {}
 
-            /// Construct object for specified state
+            /// Construct object in specified state
             explicit reentrant_spin_lock( bool bLocked )
                 : m_spin(0)
                 , m_OwnerId( OS::c_NullThreadId )
@@ -340,7 +340,7 @@ namespace cds {
             /// Unlock the spin-lock. Return \p true if the current thread is owner of spin-lock \p false otherwise
             bool unlock() CDS_NOEXCEPT
             {
-                if ( is_taken( OS::get_current_thread_id()) ) {
+                if ( is_taken( OS::get_current_thread_id())) {
                     integral_type n = m_spin.load( atomics::memory_order_relaxed );
                     if ( n > 1 )
                         m_spin.store( n - 1, atomics::memory_order_relaxed );
@@ -356,7 +356,7 @@ namespace cds {
             /// Change the owner of locked spin-lock. May be called by thread that is owner of the spin-lock
             bool change_owner( OS::ThreadId newOwnerId ) CDS_NOEXCEPT
             {
-                if ( is_taken( OS::get_current_thread_id()) ) {
+                if ( is_taken( OS::get_current_thread_id())) {
                     assert( newOwnerId != OS::c_NullThreadId );
                     m_OwnerId = newOwnerId;
                     return true;