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;
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 ) {
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 ) {
{
*/
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();
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;
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;
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 ) {
*/
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 );
CDS_DEBUG_ONLY(
if ( !bCurrent ) {
- m_dbgOwnerId = OS::getCurrentThreadId();
+ m_dbgOwnerId = OS::get_current_thread_id();
}
)
return !bCurrent;
backoff_strategy backoff;
// Deadlock detected
- assert( m_dbgOwnerId != OS::getCurrentThreadId() );
+ assert( m_dbgOwnerId != OS::get_current_thread_id() );
// TATAS algorithm
while ( !try_lock() ) {
backoff();
}
}
- assert( m_dbgOwnerId == OS::getCurrentThreadId() );
+ assert( m_dbgOwnerId == OS::get_current_thread_id() );
}
/// Unlock the spin-lock. Debug version: deadlock may be detected
{
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 );
*/
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()) {
/// 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 )) {
/// 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 );
/// 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 );
/// 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;
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();
}
}
} // 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
typedef DWORD ThreadId;
/// Get current thread id
- static inline ThreadId getCurrentThreadId()
+ static inline ThreadId get_current_thread_id()
{
return ::GetCurrentThreadId();
}
#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT
using Win32::ThreadId;
- using Win32::getCurrentThreadId;
+ using Win32::get_current_thread_id;
using Win32::isThreadAlive;
#endif
//@endcond
{
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 ) {
{
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 ) {
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
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 );
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 ) {
{
CDS_HAZARDPTR_STATISTIC( ++m_Stat.m_HelpScanCallCount )
- assert( static_cast<hplist_node *>(pThis)->m_idOwner.load(atomics::memory_order_relaxed) == cds::OS::getCurrentThreadId() );
+ assert( static_cast<hplist_node *>(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
, nData(0)
, nEnsureCall(0)
, bInitialized( false )
- , threadId( cds::OS::getCurrentThreadId() )
+ , threadId( cds::OS::get_current_thread_id() )
{}
value_type( value_type const& s )
, 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 =
, nData(0)
, nEnsureCall(0)
, bInitialized( false )
- , threadId( cds::OS::getCurrentThreadId() )
+ , threadId( cds::OS::get_current_thread_id() )
{}
value_type( value_type const& s )
, 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 =