From 0fd75ab4c1149b56a1bd6d0749f763a3430317ed Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 30 Sep 2014 23:47:20 +0400 Subject: [PATCH] Refactoring cds/lock/array.h --- cds/lock/array.h | 12 +++++------- cds/lock/scoped_lock.h | 2 +- cds/lock/spinlock.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cds/lock/array.h b/cds/lock/array.h index dabcaba3..ce94189a 100644 --- a/cds/lock/array.h +++ b/cds/lock/array.h @@ -1,4 +1,4 @@ -//$$CDS-header$$ +//$$CDS-header$$-2 #ifndef __CDS_LOCK_ARRAY_H #define __CDS_LOCK_ARRAY_H @@ -212,8 +212,7 @@ namespace cds { namespace lock { { size_t nCell = m_SelectCellPolicy( hint, size() ); assert( nCell < size() ); - lock_type& l = m_arrLocks[ nCell ]; - l.lock(); + m_arrLocks[nCell].lock(); return nCell; } @@ -229,8 +228,7 @@ namespace cds { namespace lock { { size_t nCell = m_SelectCellPolicy( hint, size() ); assert( nCell < size() ); - lock_type& l = m_arrLocks[ nCell ]; - if ( l.try_lock() ) + if ( m_arrLocks[nCell].try_lock() ) return nCell; return c_nUnspecifiedCell; } @@ -246,7 +244,7 @@ namespace cds { namespace lock { void lock_all() { lock_type * pLock = m_arrLocks; - for ( size_t i = 0; i < size(); ++i, ++pLock ) + for ( lock_type * pEnd = m_arrLocks + size(); pLock != pEnd; ++pLock ) pLock->lock(); } @@ -254,7 +252,7 @@ namespace cds { namespace lock { void unlock_all() { lock_type * pLock = m_arrLocks; - for ( size_t i = 0; i < size(); ++i, ++pLock ) + for ( lock_type * pEnd = m_arrLocks + size(); pLock != pEnd; ++pLock ) pLock->unlock(); } diff --git a/cds/lock/scoped_lock.h b/cds/lock/scoped_lock.h index 85423678..13b78f25 100644 --- a/cds/lock/scoped_lock.h +++ b/cds/lock/scoped_lock.h @@ -1,4 +1,4 @@ -//$$CDS-header$$ +//$$CDS-header$$-2 #ifndef __CDS_LOCK_SCOPED_LOCK_H #define __CDS_LOCK_SCOPED_LOCK_H diff --git a/cds/lock/spinlock.h b/cds/lock/spinlock.h index e4248a5f..119cd8f8 100644 --- a/cds/lock/spinlock.h +++ b/cds/lock/spinlock.h @@ -1,4 +1,4 @@ -//$$CDS-header$$ +//$$CDS-header$$-2 #ifndef __CDS_LOCK_SPINLOCK_H #define __CDS_LOCK_SPINLOCK_H -- 2.34.1