#include <memory>
#include <functional> // ref
+#include <mutex> // unique_lock
#include <cds/opt/options.h>
#include <cds/lock/spinlock.h>
#include <cds/intrusive/details/queue_stat.h>
protected:
//@cond
typedef typename opt::details::alignment_setter< lock_type, options::alignment >::type aligned_lock_type;
- typedef cds::lock::scoped_lock<lock_type> auto_lock;
+ typedef std::unique_lock<lock_type> auto_lock;
typedef cds::details::Allocator< node_type, allocator_type > node_allocator;
item_counter m_ItemCounter;
#ifndef __CDS_GC_PTB_PASS_THE_BUCK_H
#define __CDS_GC_PTB_PASS_THE_BUCK_H
+#include <mutex> // unique_lock
#include <cds/cxx11_atomic.h>
#include <cds/gc/details/retired_ptr.h>
#include <cds/details/aligned_allocator.h>
#include <cds/details/allocator.h>
#include <cds/details/noncopyable.h>
-
#include <cds/lock/spinlock.h>
#if CDS_COMPILER == CDS_COMPILER_MSVC
details::guard_data * pGuard;
{
- cds::lock::scoped_lock<SpinLock> al( m_freeListLock );
+ std::unique_lock<SpinLock> al( m_freeListLock );
pGuard = m_FreeGuardList.load(atomics::memory_order_relaxed);
if ( pGuard )
m_FreeGuardList.store( pGuard->pNextFree.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed );
{
pGuard->pPost.store( nullptr, atomics::memory_order_relaxed );
- cds::lock::scoped_lock<SpinLock> al( m_freeListLock );
+ std::unique_lock<SpinLock> al( m_freeListLock );
pGuard->pNextFree.store( m_FreeGuardList.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed );
m_FreeGuardList.store( pGuard, atomics::memory_order_relaxed );
}
pLast = p;
}
- cds::lock::scoped_lock<SpinLock> al( m_freeListLock );
+ std::unique_lock<SpinLock> al( m_freeListLock );
pLast->pNextFree.store( m_FreeGuardList.load(atomics::memory_order_relaxed), atomics::memory_order_relaxed );
m_FreeGuardList.store( pList, atomics::memory_order_relaxed );
}
lock_array( size_t nCapacity ): lock_array_type( nCapacity, typename lock_array_type::select_cell_policy(nCapacity) ) {}
};
- class scoped_lock: public cds::lock::scoped_lock< lock_array_type >
+ class scoped_lock: public std::unique_lock< lock_array_type >
{
- typedef cds::lock::scoped_lock< lock_array_type > base_class;
+ typedef std::unique_lock< lock_array_type > base_class;
public:
scoped_lock( lock_array& arrLock, size_t nHash ): base_class( arrLock, nHash ) {}
};
};
class scoped_full_lock {
- cds::lock::scoped_lock< lock_array_type > m_guard;
+ std::unique_lock< lock_array_type > m_guard;
public:
scoped_full_lock( striping& policy )
: m_guard( policy.m_Locks[0] )
typedef cds::OS::ThreadId threadId_t;
typedef cds::lock::Spin spinlock_type;
- typedef cds::lock::scoped_lock< spinlock_type > scoped_spinlock;
+ typedef std::unique_lock< spinlock_type > scoped_spinlock;
//@endcond
protected:
#ifndef __CDS_INTRUSIVE_IMPL_LAZY_LIST_H
#define __CDS_INTRUSIVE_IMPL_LAZY_LIST_H
+#include <mutex> // unique_lock
#include <cds/intrusive/details/lazy_list_base.h>
#include <cds/gc/guarded_ptr.h>
search( pHead, val, pos, cmp );
if ( pos.pCur != tail() ) {
- cds::lock::scoped_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
+ std::unique_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
if ( !pos.pCur->is_marked()
&& cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
{
#ifndef __CDS_INTRUSIVE_LAZY_LIST_NOGC_H
#define __CDS_INTRUSIVE_LAZY_LIST_NOGC_H
+#include <mutex> // unique_lock
#include <cds/intrusive/details/lazy_list_base.h>
#include <cds/gc/nogc.h>
search( pHead, val, pos, cmp );
if ( pos.pCur != &m_Tail ) {
- cds::lock::scoped_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
+ std::unique_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
if ( cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
{
f( *node_traits::to_value_ptr( *pos.pCur ), val );
search( pHead, val, pos, cmp );
if ( pos.pCur != &m_Tail ) {
- cds::lock::scoped_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
+ std::unique_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
if ( cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
{
return iterator( pos.pCur );
#ifndef __CDS_INTRUSIVE_LAZY_LIST_RCU_H
#define __CDS_INTRUSIVE_LAZY_LIST_RCU_H
+#include <mutex> // unique_lock
#include <cds/intrusive/details/lazy_list_base.h>
#include <cds/urcu/details/check_deadlock.h>
#include <cds/details/binary_functor_wrapper.h>
rcu_lock l( bLock );
search( pHead, val, pos, cmp );
if ( pos.pCur != &m_Tail ) {
- cds::lock::scoped_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
+ std::unique_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
if ( cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
{
f( *node_traits::to_value_ptr( *pos.pCur ), val );
search( pHead, val, pos, cmp );
if ( pos.pCur != &m_Tail ) {
- cds::lock::scoped_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
+ std::unique_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
if ( cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
{
return const_iterator( pos.pCur );
typedef cds::OS::ThreadId threadId_t;
typedef cds::lock::Spin spinlock_type;
- typedef cds::lock::scoped_lock< spinlock_type > scoped_spinlock;
+ typedef std::unique_lock< spinlock_type > scoped_spinlock;
//@endcond
protected:
public:
//@cond
class scoped_cell_lock {
- cds::lock::scoped_lock< lock_type > m_guard;
+ std::unique_lock< lock_type > m_guard;
public:
scoped_cell_lock( refinable& policy, size_t nHash )
- : m_guard( policy.acquire( nHash ), true )
+ : m_guard( policy.acquire( nHash ), std::adopt_lock_t() )
{}
};
#include <type_traits>
#include <functional> // ref
+#include <mutex> // unique_lock
#include <cds/intrusive/details/single_link_struct.h>
#include <cds/algo/elimination.h>
#include <cds/opt/buffer.h>
#include <cds/lock/spinlock.h>
-#include <cds/lock/scoped_lock.h>
#include <cds/details/type_padding.h>
namespace cds { namespace intrusive {
op_collided = 2
};
- typedef cds::lock::scoped_lock< elimination_lock_type > slot_scoped_lock;
+ typedef std::unique_lock< elimination_lock_type > slot_scoped_lock;
public:
elimination_backoff()
#ifndef __CDS_LOCK_ARRAY_H
#define __CDS_LOCK_ARRAY_H
+#include <mutex> //unique_lock
#include <cds/details/allocator.h>
-#include <cds/lock/scoped_lock.h>
#include <cds/algo/int_algo.h>
-
#include <boost/mpl/if.hpp>
namespace cds { namespace lock {
}
};
+}} // namespace cds::lock
+
+//@cond
+namespace std {
+
/// Specialization \ref scoped_lock for lock::array
template <typename Lock, typename SelectPolicy, class Alloc>
- class scoped_lock< cds::lock::array< Lock, SelectPolicy, Alloc > >: public cds::details::noncopyable
+ class unique_lock< cds::lock::array< Lock, SelectPolicy, Alloc > >
{
public:
- typedef cds::lock::array< Lock, SelectPolicy, Alloc > lock_array_type ; ///< Lock array type
+ typedef cds::lock::array< Lock, SelectPolicy, Alloc > lock_array_type; ///< Lock array type
private:
- //@cond
lock_array_type& m_arrLocks;
size_t m_nLockGuarded;
- static const size_t c_nLockAll = ~size_t(0);
- //@endcond
+ static const size_t c_nLockAll = ~size_t( 0 );
public:
/// Onws the lock array \p arrLocks and locks a cell determined by \p hint parameter
template <typename Q>
- scoped_lock( lock_array_type& arrLocks, Q const& hint )
+ unique_lock( lock_array_type& arrLocks, Q const& hint )
: m_arrLocks( arrLocks )
- , m_nLockGuarded( arrLocks.lock( hint ))
+ , m_nLockGuarded( arrLocks.lock( hint ) )
{}
/// Locks all from \p arrLocks array
- scoped_lock( lock_array_type& arrLocks )
+ unique_lock( lock_array_type& arrLocks )
: m_arrLocks( arrLocks )
, m_nLockGuarded( c_nLockAll )
{
arrLocks.lock_all();
}
- ~scoped_lock()
+ unique_lock() = delete;
+ unique_lock( unique_lock const& ) = delete;
+
+ ~unique_lock()
{
if ( m_nLockGuarded == c_nLockAll )
m_arrLocks.unlock_all();
m_arrLocks.unlock( m_nLockGuarded );
}
};
-
-}} // namespace cds::lock
+} // namespace std
+//@endcond
#endif // #ifndef __CDS_LOCK_ARRAY_H
+++ /dev/null
-//$$CDS-header$$-2
-
-#ifndef __CDS_LOCK_SCOPED_LOCK_H
-#define __CDS_LOCK_SCOPED_LOCK_H
-
-#include <cds/details/defs.h>
-#include <cds/details/noncopyable.h>
-
-namespace cds { namespace lock {
-
- /// Scoped lock
- /**
-
- An object of type \p scoped_lock controls the ownership of a lockable object within a scope.
- A \p scoped_lock object maintains ownership of a lockable object throughout the \p scoped_lock object\92s lifetime.
- The behavior of a program is undefined if the lockable object does not exist for the entire lifetime
- of the \p scoped_lock object.
- The supplied \p Lock type shall have two methods: \p lock and \p unlock.
-
- The constructor locks the wrapped lock object, the destructor unlocks it.
-
- Scoped lock is not copy-constructible and not default-constructible.
-
- This class is similar to \p std::lock_quard
- */
- template <class Lock>
- class scoped_lock: public cds::details::noncopyable
- {
- public:
- typedef Lock lock_type ; ///< Lock type
-
- protected:
- lock_type& m_Lock ; ///< Owned lock object
-
- protected:
- //@cond
- // Only for internal use!!!
- scoped_lock()
- {}
- //@endcond
- public:
- /// Get ownership of lock object \p l and calls <tt>l.lock()</tt>
- scoped_lock( lock_type& l )
- : m_Lock( l )
- {
- l.lock();
- }
-
- /// Get ownership of lock object \p l and conditionally locks it
- /**
- The constructor calls <tt>l.lock()</tt> only if \p bAlreadyLocked is \p false.
- If \p bAlreadyLocked is \p true, no locking is performed.
-
- In any case, the destructor of \p scoped_lock object invokes <tt>l.unlock()</tt>.
- */
- scoped_lock( lock_type& l, bool bAlreadyLocked )
- : m_Lock( l )
- {
- if ( !bAlreadyLocked )
- l.lock();
- }
-
- /// Unlock underlying lock object and release ownership
- ~scoped_lock()
- {
- m_Lock.unlock();
- }
- };
-}} // namespace cds::lock
-
-
-#endif // #ifndef __CDS_LOCK_SCOPED_LOCK_H
#include <cds/cxx11_atomic.h>
#include <cds/os/thread.h>
#include <cds/algo/backoff_strategy.h>
-#include <cds/lock/scoped_lock.h>
#include <cds/details/noncopyable.h>
2011.01.02 khizmax Created
*/
+#include <stdlib.h>
+#include <mutex> // unique_lock
#include <cds/init.h>
#include <cds/memory/michael/options.h>
#include <cds/memory/michael/bound_check.h>
#include <cds/user_setup/cache_line.h>
#include <cds/details/lib.h>
-#include <stdlib.h>
#include <boost/intrusive/list.hpp>
namespace cds {
typedef details::free_list_locked_hook item_hook;
typedef Lock lock_type;
protected:
- typedef cds::lock::scoped_lock<lock_type> auto_lock;
+ typedef std::unique_lock<lock_type> auto_lock;
mutable lock_type m_access;
//@endcond
typedef details::partial_list_locked_hook item_hook;
typedef Lock lock_type;
protected:
- typedef cds::lock::scoped_lock<lock_type> auto_lock;
+ typedef std::unique_lock<lock_type> auto_lock;
mutable lock_type m_access;
//@endcond
uint64_t nEpoch;
atomics::atomic_thread_fence( atomics::memory_order_acquire );
{
- cds::lock::scoped_lock<lock_type> sl( m_Lock );
+ std::unique_lock<lock_type> sl( m_Lock );
if ( ep.m_p && m_Buffer.push( ep ) )
return false;
nEpoch = m_nCurEpoch.fetch_add( 1, atomics::memory_order_relaxed );
#include <mutex>
#include <cds/urcu/details/gp.h>
#include <cds/algo/backoff_strategy.h>
-#include <cds/lock/scoped_lock.h>
namespace cds { namespace urcu {
{
atomics::atomic_thread_fence( atomics::memory_order_acquire );
{
- cds::lock::scoped_lock<lock_type> sl( m_Lock );
+ std::unique_lock<lock_type> sl( m_Lock );
flip_and_wait();
flip_and_wait();
}
#ifndef _CDS_URCU_DETAILS_GPT_H
#define _CDS_URCU_DETAILS_GPT_H
+#include <mutex> //unique_lock
#include <cds/urcu/details/gp.h>
#include <cds/urcu/dispose_thread.h>
#include <cds/algo/backoff_strategy.h>
atomics::atomic_thread_fence( atomics::memory_order_acquire );
{
- cds::lock::scoped_lock<lock_type> sl( m_Lock );
+ std::unique_lock<lock_type> sl( m_Lock );
flip_and_wait();
flip_and_wait();
uint64_t nEpoch;
atomics::atomic_thread_fence( atomics::memory_order_acquire );
{
- cds::lock::scoped_lock<lock_type> sl( m_Lock );
+ std::unique_lock<lock_type> sl( m_Lock );
if ( ep.m_p && m_Buffer.push( ep ) && m_Buffer.size() < capacity())
return false;
nEpoch = m_nCurEpoch.fetch_add( 1, atomics::memory_order_relaxed );
#ifndef _CDS_URCU_DETAILS_SIG_THREADED_H
#define _CDS_URCU_DETAILS_SIG_THREADED_H
+#include <mutex> //unique_lock
#include <cds/urcu/details/sh.h>
#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
atomics::atomic_thread_fence( atomics::memory_order_acquire );
{
- cds::lock::scoped_lock<lock_type> sl( m_Lock );
+ std::unique_lock<lock_type> sl( m_Lock );
back_off bkOff;
base_class::force_membar_all_threads( bkOff );
<ClInclude Include="..\..\..\cds\intrusive\striped_set\resizing_policy.h" />\r
<ClInclude Include="..\..\..\cds\intrusive\striped_set\striping_policy.h" />\r
<ClInclude Include="..\..\..\cds\lock\array.h" />\r
- <ClInclude Include="..\..\..\cds\lock\scoped_lock.h" />\r
<ClInclude Include="..\..\..\cds\memory\mapper.h" />\r
<ClInclude Include="..\..\..\cds\memory\pool_allocator.h" />\r
<ClInclude Include="..\..\..\cds\memory\vyukov_queue_pool.h" />\r
<ClInclude Include="..\..\..\cds\lock\array.h">\r
<Filter>Header Files\cds\lock</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\..\..\cds\lock\scoped_lock.h">\r
- <Filter>Header Files\cds\lock</Filter>\r
- </ClInclude>\r
<ClInclude Include="..\..\..\cds\container\details\make_split_list_set.h">\r
<Filter>Header Files\cds\container\details</Filter>\r
</ClInclude>\r
//$$CDS-header$$
#include <functional>
+#include <mutex> //unique_lock
#include "map2/map_types.h"
#include "cppunit/thread.h"
void operator()( pair_type& val )
{
- cds::lock::scoped_lock< typename value_type::lock_type> ac( val.second.m_access );
+ std::unique_lock< typename value_type::lock_type> ac( val.second.m_access );
val.second.nKey = val.first;
val.second.nData = val.first * 8;
void operator()( bool bNew, pair_type& val )
{
- cds::lock::scoped_lock<typename value_type::lock_type> ac( val.second.m_access );
+ std::unique_lock<typename value_type::lock_type> ac( val.second.m_access );
if ( bNew ) {
++nCreated;
val.second.nKey = val.first;
{
while ( true ) {
if ( item.second.bInitialized.load( atomics::memory_order_relaxed )) {
- cds::lock::scoped_lock< typename value_type::lock_type> ac( item.second.m_access );
+ std::unique_lock< typename value_type::lock_type> ac( item.second.m_access );
if ( m_cnt.nKeyExpected == item.second.nKey && m_cnt.nKeyExpected * 8 == item.second.nData )
++m_cnt.nSuccessItem;
#ifndef __CDSUNIT_STD_HASH_MAP_GCC_H
#define __CDSUNIT_STD_HASH_MAP_GCC_H
+#include <mutex> //unique_lock
#include <unordered_map>
#include <functional> // ref
{
public:
Lock m_lock;
- typedef cds::lock::scoped_lock<Lock> AutoLock;
+ typedef std::unique_lock<Lock> AutoLock;
typedef std::unordered_map<
Key, Value
, std::hash<Key>
#include <hash_map>
#include <functional> // ref
+#include <mutex> //unique_lock
namespace map2 {
template <typename Key, typename Value, typename Lock, class Alloc = CDS_DEFAULT_ALLOCATOR>
{
public:
Lock m_lock;
- typedef cds::lock::scoped_lock<Lock> AutoLock;
+ typedef std::unique_lock<Lock> AutoLock;
typedef stdext::hash_map<Key, Value, stdext::hash_compare<Key, std::less<Key> >, Alloc> base_class;
public:
typedef typename base_class::mapped_type value_type;
#include <map>
#include <functional> // ref
+#include <mutex> //unique_lock
namespace map2 {
class StdMap: public std::map<Key, Value, std::less<Key>, Alloc>
{
Lock m_lock;
- typedef cds::lock::scoped_lock<Lock> AutoLock;
+ typedef std::unique_lock<Lock> AutoLock;
typedef std::map<Key, Value, std::less<Key>, Alloc> base_class;
public:
typedef typename base_class::mapped_type value_type;
#include <map>
#include <functional> // ref
+#include <mutex> //unique_lock
namespace map2 {
template <typename Key, typename Value, typename Lock, class Alloc = CDS_DEFAULT_ALLOCATOR>
class StdMap: public std::map<Key, Value, std::less<Key>, Alloc>
{
Lock m_lock;
- typedef cds::lock::scoped_lock<Lock> AutoLock;
+ typedef std::unique_lock<Lock> AutoLock;
typedef std::map<Key, Value, std::less<Key>, Alloc> base_class;
public:
typedef typename base_class::mapped_type value_type;
#define __CDSUNIT_STD_PQUEUE_H
#include <queue>
+#include <mutex> //unique_lock
namespace pqueue {
pqueue_type m_PQueue;
mutable Lock m_Lock;
- struct scoped_lock
- {
- Lock& m_lock;
-
- scoped_lock( Lock& l )
- : m_lock(l)
- {
- l.lock();
- }
-
- ~scoped_lock()
- {
- m_lock.unlock();
- }
- };
+ typedef std::unique_lock<Lock> scoped_lock;
public:
bool push( value_type const& val )
#ifndef __UNIT_QUEUE_STD_QUEUE_H
#define __UNIT_QUEUE_STD_QUEUE_H
+#include <mutex> //unique_lock
#include <queue>
#include <cds/lock/spinlock.h>
public:
bool enqueue( const T& data )
{
- cds::lock::scoped_lock<Lock> a(m_Locker);
+ std::unique_lock<Lock> a(m_Locker);
base_class::push( data );
return true;
bool push( const T& data ) { return enqueue( data ) ; }
bool dequeue( T& data )
{
- cds::lock::scoped_lock<Lock> a(m_Locker);
+ std::unique_lock<Lock> a(m_Locker);
if ( base_class::empty() )
return false;
#include <functional>
#include <vector>
+#include <mutex> //unique_lock
#include "set2/set_types.h"
#include "cppunit/thread.h"
void operator()( keyval_type& val )
{
- cds::lock::scoped_lock< typename value_type::lock_type> ac( val.val.m_access );
+ std::unique_lock< typename value_type::lock_type> ac( val.val.m_access );
val.val.nKey = val.key;
val.val.nData = val.key * 8;
void operator()( bool bNew, keyval_type& val, size_t nKey )
{
- cds::lock::scoped_lock<typename value_type::lock_type> ac( val.val.m_access );
+ std::unique_lock<typename value_type::lock_type> ac( val.val.m_access );
if ( !val.val.bInitialized )
{
val.val.nKey = val.key;
while ( true ) {
bool bBkoff = false;
{
- cds::lock::scoped_lock< typename value_type::lock_type> ac( item.val.m_access );
+ std::unique_lock< typename value_type::lock_type> ac( item.val.m_access );
if ( item.val.bInitialized ) {
if ( m_cnt.nKeyExpected == item.val.nKey && m_cnt.nKeyExpected * 8 == item.val.nData )
++m_cnt.nSuccessItem;
#include <unordered_set>
#include <functional> // ref
+#include <mutex> //unique_lock
namespace set2 {
{
public:
Lock m_lock;
- typedef cds::lock::scoped_lock<Lock> AutoLock;
+ typedef std::unique_lock<Lock> AutoLock;
typedef std::unordered_set<
Value
, Hash
#define __CDSUNIT_STD_HASH_SET_VC_H
#include <hash_set>
+#include <mutex> //unique_lock
namespace set2 {
{
public:
Lock m_lock;
- typedef cds::lock::scoped_lock<Lock> AutoLock;
+ typedef std::unique_lock<Lock> AutoLock;
typedef stdext::hash_set<Value, hash_less<Value, Hash, Less >, Alloc> base_class;
public:
#include <set>
#include <functional> // ref
+#include <mutex> //unique_lock
namespace set2 {
template <typename Value, typename Less, typename Lock,
class StdSet: public std::set<Value, Less, Alloc>
{
Lock m_lock;
- typedef cds::lock::scoped_lock<Lock> AutoLock;
+ typedef std::unique_lock<Lock> AutoLock;
typedef std::set<Value, Less, Alloc> base_class;
public:
typedef typename base_class::key_type value_type;