From: khizmax Date: Sat, 29 Nov 2014 11:45:12 +0000 (+0300) Subject: Renamed getCurrentThreadId to get_current_thread_id X-Git-Tag: v2.0.0~40 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=49564c8304990644031b14fc8adb73aad594cc87 Renamed getCurrentThreadId to get_current_thread_id --- diff --git a/cds/intrusive/cuckoo_set.h b/cds/intrusive/cuckoo_set.h index aa0e2442..e747ac37 100644 --- a/cds/intrusive/cuckoo_set.h +++ b/cds/intrusive/cuckoo_set.h @@ -679,7 +679,7 @@ namespace cds { namespace intrusive { void acquire( size_t const * arrHash, lock_array_ptr * pLockArr, lock_type ** parrLock ) { - owner_t me = (owner_t) cds::OS::getCurrentThreadId(); + owner_t me = (owner_t) cds::OS::get_current_thread_id(); owner_t who; back_off bkoff; @@ -758,7 +758,7 @@ namespace cds { namespace intrusive { void acquire_all() { - owner_t me = (owner_t) cds::OS::getCurrentThreadId(); + owner_t me = (owner_t) cds::OS::get_current_thread_id(); back_off bkoff; while ( true ) { @@ -782,7 +782,7 @@ namespace cds { namespace intrusive { void acquire_resize( lock_array_ptr * pOldLocks ) { - owner_t me = (owner_t) cds::OS::getCurrentThreadId(); + owner_t me = (owner_t) cds::OS::get_current_thread_id(); while ( true ) { { diff --git a/cds/intrusive/mspriority_queue.h b/cds/intrusive/mspriority_queue.h index 2788fa3a..eca32914 100644 --- a/cds/intrusive/mspriority_queue.h +++ b/cds/intrusive/mspriority_queue.h @@ -240,7 +240,7 @@ namespace cds { namespace intrusive { */ bool push( value_type& val ) { - tag_type const curId = cds::OS::getCurrentThreadId(); + tag_type const curId = cds::OS::get_current_thread_id(); // Insert new item at bottom of the heap m_Lock.lock(); diff --git a/cds/intrusive/striped_set/striping_policy.h b/cds/intrusive/striped_set/striping_policy.h index 46333d64..8404bde9 100644 --- a/cds/intrusive/striped_set/striping_policy.h +++ b/cds/intrusive/striped_set/striping_policy.h @@ -175,7 +175,7 @@ namespace cds { namespace intrusive { namespace striped_set { lock_type& acquire( size_t nHash ) { - owner_t me = (owner_t) cds::OS::getCurrentThreadId(); + owner_t me = (owner_t) cds::OS::get_current_thread_id(); owner_t who; back_off bkoff; @@ -206,7 +206,7 @@ namespace cds { namespace intrusive { namespace striped_set { lock_array_ptr acquire_all() { - owner_t me = (owner_t) cds::OS::getCurrentThreadId(); + owner_t me = (owner_t) cds::OS::get_current_thread_id(); owner_t who; back_off bkoff; @@ -242,7 +242,7 @@ namespace cds { namespace intrusive { namespace striped_set { bool acquire_resize() { - owner_t me = (owner_t) cds::OS::getCurrentThreadId(); + owner_t me = (owner_t) cds::OS::get_current_thread_id(); back_off bkoff; for (unsigned int nAttempts = 0; nAttempts < 32; ++nAttempts ) { diff --git a/cds/lock/spinlock.h b/cds/lock/spinlock.h index b5bf19ed..dbe729db 100644 --- a/cds/lock/spinlock.h +++ b/cds/lock/spinlock.h @@ -70,7 +70,7 @@ namespace cds { */ Spinlock( bool bLocked ) CDS_NOEXCEPT # ifdef CDS_DEBUG - : m_dbgOwnerId( bLocked ? OS::getCurrentThreadId() : OS::c_NullThreadId ) + : m_dbgOwnerId( bLocked ? OS::get_current_thread_id() : OS::c_NullThreadId ) # endif { m_spin.store( bLocked, atomics::memory_order_relaxed ); @@ -115,7 +115,7 @@ namespace cds { CDS_DEBUG_ONLY( if ( !bCurrent ) { - m_dbgOwnerId = OS::getCurrentThreadId(); + m_dbgOwnerId = OS::get_current_thread_id(); } ) return !bCurrent; @@ -143,7 +143,7 @@ namespace cds { backoff_strategy backoff; // Deadlock detected - assert( m_dbgOwnerId != OS::getCurrentThreadId() ); + assert( m_dbgOwnerId != OS::get_current_thread_id() ); // TATAS algorithm while ( !try_lock() ) { @@ -151,7 +151,7 @@ namespace cds { backoff(); } } - assert( m_dbgOwnerId == OS::getCurrentThreadId() ); + assert( m_dbgOwnerId == OS::get_current_thread_id() ); } /// Unlock the spin-lock. Debug version: deadlock may be detected @@ -159,7 +159,7 @@ namespace cds { { assert( m_spin.load( atomics::memory_order_relaxed ) ); - assert( m_dbgOwnerId == OS::getCurrentThreadId() ); + assert( m_dbgOwnerId == OS::get_current_thread_id() ); CDS_DEBUG_ONLY( m_dbgOwnerId = OS::c_NullThreadId; ) m_spin.store( false, atomics::memory_order_release ); @@ -279,13 +279,13 @@ namespace cds { */ bool is_locked() const CDS_NOEXCEPT { - return !( m_spin.load( atomics::memory_order_relaxed ) == 0 || is_taken( cds::OS::getCurrentThreadId() )); + return !( m_spin.load( atomics::memory_order_relaxed ) == 0 || is_taken( cds::OS::get_current_thread_id() )); } /// Try to lock the spin-lock (synonym for \ref try_lock) bool try_lock() CDS_NOEXCEPT { - thread_id tid = OS::getCurrentThreadId(); + thread_id tid = OS::get_current_thread_id(); if ( try_taken_lock( tid ) ) return true; if ( try_acquire()) { @@ -298,7 +298,7 @@ namespace cds { /// Try to lock the object bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( try_acquire( nTryCount ) ) ) { - thread_id tid = OS::getCurrentThreadId(); + thread_id tid = OS::get_current_thread_id(); if ( try_taken_lock( tid ) ) return true; if ( try_acquire( nTryCount )) { @@ -311,7 +311,7 @@ namespace cds { /// Lock the object waits if it is busy void lock() CDS_NOEXCEPT { - thread_id tid = OS::getCurrentThreadId(); + thread_id tid = OS::get_current_thread_id(); if ( !try_taken_lock( tid ) ) { acquire(); take( tid ); @@ -321,7 +321,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::getCurrentThreadId() ) ) { + 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 ); @@ -337,7 +337,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::getCurrentThreadId() ) ) { + if ( is_taken( OS::get_current_thread_id() ) ) { assert( newOwnerId != OS::c_NullThreadId ); m_OwnerId = newOwnerId; return true; diff --git a/cds/os/posix/thread.h b/cds/os/posix/thread.h index adaf022e..b2531847 100644 --- a/cds/os/posix/thread.h +++ b/cds/os/posix/thread.h @@ -8,13 +8,13 @@ namespace cds { namespace OS { /// posix-related wrappers - CDS_CXX11_INLINE_NAMESPACE namespace posix { + inline namespace posix { /// Posix thread id type typedef std::thread::native_handle_type ThreadId; /// Get current thread id - static inline ThreadId getCurrentThreadId() + static inline ThreadId get_current_thread_id() { return pthread_self(); } @@ -29,14 +29,9 @@ namespace cds { namespace OS { } } // namespace posix + //@cond constexpr const posix::ThreadId c_NullThreadId = 0; - -#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT - using posix::ThreadId; - - using posix::getCurrentThreadId; - using posix::isThreadAlive; -#endif + //@endcond }} // namespace cds::OS diff --git a/cds/os/win/thread.h b/cds/os/win/thread.h index 0e3d6646..15fd57f2 100644 --- a/cds/os/win/thread.h +++ b/cds/os/win/thread.h @@ -13,7 +13,7 @@ namespace cds { namespace OS { typedef DWORD ThreadId; /// Get current thread id - static inline ThreadId getCurrentThreadId() + static inline ThreadId get_current_thread_id() { return ::GetCurrentThreadId(); } @@ -34,7 +34,7 @@ namespace cds { namespace OS { #ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT using Win32::ThreadId; - using Win32::getCurrentThreadId; + using Win32::get_current_thread_id; using Win32::isThreadAlive; #endif //@endcond diff --git a/cds/urcu/details/base.h b/cds/urcu/details/base.h index bcb7c53a..b480ccff 100644 --- a/cds/urcu/details/base.h +++ b/cds/urcu/details/base.h @@ -330,7 +330,7 @@ namespace cds { { thread_record * pRec; cds::OS::ThreadId const nullThreadId = cds::OS::c_NullThreadId; - cds::OS::ThreadId const curThreadId = cds::OS::getCurrentThreadId(); + cds::OS::ThreadId const curThreadId = cds::OS::get_current_thread_id(); // First try to reuse a retired (non-active) HP record for ( pRec = m_pHead.load( atomics::memory_order_acquire ); pRec; pRec = pRec->m_list.m_pNext ) { @@ -384,7 +384,7 @@ namespace cds { { allocator_type al; CDS_DEBUG_ONLY( cds::OS::ThreadId const nullThreadId = cds::OS::c_NullThreadId; ) - CDS_DEBUG_ONLY( cds::OS::ThreadId const mainThreadId = cds::OS::getCurrentThreadId() ;) + CDS_DEBUG_ONLY( cds::OS::ThreadId const mainThreadId = cds::OS::get_current_thread_id() ;) thread_record * p = m_pHead.exchange( nullptr, atomics::memory_order_seq_cst ); while ( p ) { diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 14ce22e4..5d1a8f85 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -191,7 +191,7 @@ BOOL WINAPI DllMain( switch ( fdwReason ) { case DLL_PROCESS_ATTACH: s_DllInstance = hinstDLL; - s_MainThreadId = cds::OS::getCurrentThreadId(); + s_MainThreadId = cds::OS::get_current_thread_id(); #if _WIN32_WINNT < 0x0601 discover_topology(); #endif diff --git a/src/hp_gc.cpp b/src/hp_gc.cpp index dec6e245..7bbcb73e 100644 --- a/src/hp_gc.cpp +++ b/src/hp_gc.cpp @@ -59,7 +59,7 @@ namespace cds { namespace gc { GarbageCollector::~GarbageCollector() { CDS_DEBUG_ONLY( const cds::OS::ThreadId nullThreadId = cds::OS::c_NullThreadId; ) - CDS_DEBUG_ONLY( const cds::OS::ThreadId mainThreadId = cds::OS::getCurrentThreadId() ;) + CDS_DEBUG_ONLY( const cds::OS::ThreadId mainThreadId = cds::OS::get_current_thread_id() ;) hplist_node * pHead = m_pListHead.load( atomics::memory_order_relaxed ); m_pListHead.store( nullptr, atomics::memory_order_relaxed ); @@ -103,7 +103,7 @@ namespace cds { namespace gc { hplist_node * hprec; const cds::OS::ThreadId nullThreadId = cds::OS::c_NullThreadId; - const cds::OS::ThreadId curThreadId = cds::OS::getCurrentThreadId(); + const cds::OS::ThreadId curThreadId = cds::OS::get_current_thread_id(); // First try to reuse a retired (non-active) HP record for ( hprec = m_pListHead.load( atomics::memory_order_acquire ); hprec; hprec = hprec->m_pNextNode ) { @@ -290,10 +290,10 @@ namespace cds { namespace gc { { CDS_HAZARDPTR_STATISTIC( ++m_Stat.m_HelpScanCallCount ) - assert( static_cast(pThis)->m_idOwner.load(atomics::memory_order_relaxed) == cds::OS::getCurrentThreadId() ); + assert( static_cast(pThis)->m_idOwner.load(atomics::memory_order_relaxed) == cds::OS::get_current_thread_id() ); const cds::OS::ThreadId nullThreadId = cds::OS::c_NullThreadId; - const cds::OS::ThreadId curThreadId = cds::OS::getCurrentThreadId(); + const cds::OS::ThreadId curThreadId = cds::OS::get_current_thread_id(); for ( hplist_node * hprec = m_pListHead.load(atomics::memory_order_acquire); hprec; hprec = hprec->m_pNextNode ) { // If m_bFree == true then hprec->m_arrRetired is empty - we don't need to see it diff --git a/tests/unit/map2/map_insdel_func.cpp b/tests/unit/map2/map_insdel_func.cpp index 719c1c7c..46b53ddd 100644 --- a/tests/unit/map2/map_insdel_func.cpp +++ b/tests/unit/map2/map_insdel_func.cpp @@ -44,7 +44,7 @@ namespace map2 { , nData(0) , nEnsureCall(0) , bInitialized( false ) - , threadId( cds::OS::getCurrentThreadId() ) + , threadId( cds::OS::get_current_thread_id() ) {} value_type( value_type const& s ) @@ -52,7 +52,7 @@ namespace map2 { , nData(s.nData) , nEnsureCall(s.nEnsureCall.load(atomics::memory_order_relaxed)) , bInitialized( s.bInitialized.load(atomics::memory_order_relaxed) ) - , threadId( cds::OS::getCurrentThreadId() ) + , threadId( cds::OS::get_current_thread_id() ) {} // boost::container::flat_map requires operator = diff --git a/tests/unit/set2/set_insdel_func.h b/tests/unit/set2/set_insdel_func.h index 313ba0df..6c75a97c 100644 --- a/tests/unit/set2/set_insdel_func.h +++ b/tests/unit/set2/set_insdel_func.h @@ -42,7 +42,7 @@ namespace set2 { , nData(0) , nEnsureCall(0) , bInitialized( false ) - , threadId( cds::OS::getCurrentThreadId() ) + , threadId( cds::OS::get_current_thread_id() ) {} value_type( value_type const& s ) @@ -50,7 +50,7 @@ namespace set2 { , nData(s.nData) , nEnsureCall(s.nEnsureCall.load(atomics::memory_order_relaxed)) , bInitialized( s.bInitialized ) - , threadId( cds::OS::getCurrentThreadId() ) + , threadId( cds::OS::get_current_thread_id() ) {} // boost::container::flat_map requires operator =