rename cds::lock namespace to cds::sync, move corresponding .h files
authorkhizmax <libcds.dev@gmail.com>
Sat, 31 Jan 2015 13:57:28 +0000 (16:57 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sat, 31 Jan 2015 14:48:42 +0000 (17:48 +0300)
Conflicts:
projects/Win/vc12/cds.vcxproj.filters

78 files changed:
cds/algo/flat_combining.h
cds/container/details/lazy_list_base.h
cds/container/fcdeque.h
cds/container/fcpriority_queue.h
cds/container/fcqueue.h
cds/container/fcstack.h
cds/container/mspriority_queue.h
cds/container/rwqueue.h
cds/container/segmented_queue.h
cds/container/treiber_stack.h
cds/gc/details/dhp.h
cds/intrusive/cuckoo_set.h
cds/intrusive/details/lazy_list_base.h
cds/intrusive/fcqueue.h
cds/intrusive/fcstack.h
cds/intrusive/lazy_list_nogc.h
cds/intrusive/mspriority_queue.h
cds/intrusive/segmented_queue.h
cds/intrusive/striped_set/striping_policy.h
cds/intrusive/treiber_stack.h
cds/lock/array.h
cds/lock/spinlock.h
cds/memory/michael/allocator.h
cds/opt/options.h
cds/sync/injected_monitor.h [new file with mode: 0644]
cds/sync/spinlock.h [new file with mode: 0644]
change.log
projects/Win/vc12/cds.vcxproj
projects/Win/vc12/cds.vcxproj.filters
tests/test-hdr/map/hdr_refinable_hashmap_boost_flat_map.cpp
tests/test-hdr/map/hdr_refinable_hashmap_boost_list.cpp
tests/test-hdr/map/hdr_refinable_hashmap_boost_map.cpp
tests/test-hdr/map/hdr_refinable_hashmap_boost_unordered_map.cpp
tests/test-hdr/map/hdr_refinable_hashmap_hashmap_std.cpp
tests/test-hdr/map/hdr_refinable_hashmap_list.cpp
tests/test-hdr/map/hdr_refinable_hashmap_map.cpp
tests/test-hdr/map/hdr_refinable_hashmap_slist.cpp
tests/test-hdr/map/hdr_striped_hashmap_boost_flat_map.cpp
tests/test-hdr/map/hdr_striped_hashmap_boost_list.cpp
tests/test-hdr/map/hdr_striped_hashmap_boost_map.cpp
tests/test-hdr/map/hdr_striped_hashmap_boost_unordered_map.cpp
tests/test-hdr/map/hdr_striped_hashmap_hashmap_std.cpp
tests/test-hdr/map/hdr_striped_hashmap_list.cpp
tests/test-hdr/map/hdr_striped_hashmap_map.cpp
tests/test-hdr/map/hdr_striped_hashmap_slist.cpp
tests/test-hdr/set/hdr_refinable_hashset_boost_flat_set.cpp
tests/test-hdr/set/hdr_refinable_hashset_boost_list.cpp
tests/test-hdr/set/hdr_refinable_hashset_boost_set.cpp
tests/test-hdr/set/hdr_refinable_hashset_boost_stable_vector.cpp
tests/test-hdr/set/hdr_refinable_hashset_boost_unordered_set.cpp
tests/test-hdr/set/hdr_refinable_hashset_boost_vector.cpp
tests/test-hdr/set/hdr_refinable_hashset_hashset_std.cpp
tests/test-hdr/set/hdr_refinable_hashset_list.cpp
tests/test-hdr/set/hdr_refinable_hashset_set.cpp
tests/test-hdr/set/hdr_refinable_hashset_slist.cpp
tests/test-hdr/set/hdr_refinable_hashset_vector.cpp
tests/test-hdr/set/hdr_striped_hashset_boost_flat_set.cpp
tests/test-hdr/set/hdr_striped_hashset_boost_list.cpp
tests/test-hdr/set/hdr_striped_hashset_boost_set.cpp
tests/test-hdr/set/hdr_striped_hashset_boost_stable_vector.cpp
tests/test-hdr/set/hdr_striped_hashset_boost_unordered_set.cpp
tests/test-hdr/set/hdr_striped_hashset_boost_vector.cpp
tests/test-hdr/set/hdr_striped_hashset_hashset_std.cpp
tests/test-hdr/set/hdr_striped_hashset_list.cpp
tests/test-hdr/set/hdr_striped_hashset_set.cpp
tests/test-hdr/set/hdr_striped_hashset_slist.cpp
tests/test-hdr/set/hdr_striped_hashset_vector.cpp
tests/unit/alloc/random.cpp
tests/unit/lock/spinlock.cpp
tests/unit/map2/map_insdel_func.cpp
tests/unit/map2/map_types.h
tests/unit/pqueue/pqueue_type.h
tests/unit/queue/intrusive_queue_type.h
tests/unit/queue/std_queue.h
tests/unit/set2/set_insdel_func.h
tests/unit/set2/set_types.h
tests/unit/stack/intrusive_stack_type.h
tests/unit/stack/stack_type.h

index 19fc20bdd9ad3d60adfbfc17e5c7f8f7279bd20b..4bacda837eb570f85d06679e18b8733472b3e9ec 100644 (file)
@@ -7,7 +7,7 @@
 #include <cds/algo/atomic.h>
 #include <cds/details/allocator.h>
 #include <cds/algo/backoff_strategy.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <cds/opt/options.h>
 #include <cds/algo/int_algo.h>
 #include <boost/thread/tss.hpp>     // thread_specific_ptr
@@ -184,7 +184,7 @@ namespace cds { namespace algo {
         */
         struct traits
         {
-            typedef cds::lock::Spin             lock_type;  ///< Lock type
+            typedef cds::sync::spin             lock_type;  ///< Lock type
             typedef cds::backoff::delay_of<2>   back_off;   ///< Back-off strategy
             typedef CDS_DEFAULT_ALLOCATOR       allocator;  ///< Allocator used for TLS data (allocating publication_record derivatives)
             typedef empty_stat                  stat;       ///< Internal statistics
@@ -194,7 +194,7 @@ namespace cds { namespace algo {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::lock_type - mutex type, default is \p cds::lock::Spin
+            - \p opt::lock_type - mutex type, default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy, defalt is \p cds::backoff::delay_of<2>
             - \p opt::allocator - allocator type, default is \ref CDS_DEFAULT_ALLOCATOR
             - \p opt::stat - internal statistics, possible type: \ref stat, \ref empty_stat (the default)
index 583c72f0ed3cd0da44620b7bdbab48a58d2aece0..1d671fbb3a03248b4b853d6dd48439d6e1c25049 100644 (file)
@@ -36,9 +36,9 @@ namespace cds { namespace container {
 
             /// Lock type used to lock modifying items
             /**
-                Default is cds::lock::Spin
+                Default is cds::sync::spin
             */
-            typedef cds::lock::Spin                 lock_type;
+            typedef cds::sync::spin                 lock_type;
 
             /// back-off strategy used
             typedef cds::backoff::Default           back_off;
@@ -70,7 +70,7 @@ namespace cds { namespace container {
         /// Metafunction converting option list to \p lazy_list::traits
         /**
             \p Options are:
-            - \p opt::lock_type - lock type for node-level locking. Default \p is cds::lock::Spin. Note that <b>each</b> node
+            - \p opt::lock_type - lock type for node-level locking. Default \p is cds::sync::spin. Note that <b>each</b> node
                 of the list has member of type \p lock_type, therefore, heavy-weighted locking primitive is not
                 acceptable as candidate for \p lock_type.
             - \p opt::compare - key compare functor. No default functor is provided.
index 481ee4253bbf9bca2af2fa14a6399e743a4843db..02af3fa2d857ee5622f7ba49b88d40661aaf7624 100644 (file)
@@ -66,7 +66,7 @@ namespace cds { namespace container {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::lock_type - mutex type, default is \p cds::lock::Spin
+            - \p opt::lock_type - mutex type, default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy, defalt is \p cds::backoff::delay_of<2>
             - \p opt::allocator - allocator type, default is \ref CDS_DEFAULT_ALLOCATOR
             - \p opt::stat - internal statistics, possible type: \ref stat, \ref empty_stat (the default)
index 9707ce04123ba4e6055e3d3d0e8f31ad9d2866f8..37c40fe05ec171cd346b80ea6759f0df91d5f14f 100644 (file)
@@ -52,7 +52,7 @@ namespace cds { namespace container {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::lock_type - mutex type, default is \p cds::lock::Spin
+            - \p opt::lock_type - mutex type, default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy, defalt is \p cds::backoff::delay_of<2>
             - \p opt::allocator - allocator type, default is \ref CDS_DEFAULT_ALLOCATOR
             - \p opt::stat - internal statistics, possible type: \p fcpqueue::stat, \p fcpqueue::empty_stat (the default)
index f069487836ee1a27e050414aaf1dd5d45214ba7e..16cf213acd20992c87fc648dac8edf5ff6b7a5f3 100644 (file)
@@ -56,7 +56,7 @@ namespace cds { namespace container {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::lock_type - mutex type, default is \p cds::lock::Spin
+            - \p opt::lock_type - mutex type, default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy, defalt is \p cds::backoff::delay_of<2>
             - \p opt::allocator - allocator type, default is \ref CDS_DEFAULT_ALLOCATOR
             - \p opt::stat - internal statistics, possible type: \p fcqueue::stat, \p fcqueue::empty_stat (the default)
index 0dbf5a8f4790339e9efe9814e0b7ae9df5db71fe..9319e1645afbaf2f14e75e8ae606111bf7827fe4 100644 (file)
@@ -56,7 +56,7 @@ namespace cds { namespace container {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::lock_type - mutex type, default is \p cds::lock::Spin
+            - \p opt::lock_type - mutex type, default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy, defalt is \p cds::backoff::Default
             - \p opt::allocator - allocator type, default is \ref CDS_DEFAULT_ALLOCATOR
             - \p opt::stat - internal statistics, possible type: \p fcstack::stat, \p fcstack::empty_stat (the default)
index 1bc48565448bf1a07d00cfe53d3ec31867262a27..a99c8193d65a3ba45d8a218870632c0c1242a8b2 100644 (file)
@@ -55,7 +55,7 @@ namespace cds { namespace container {
             - \p opt::compare - priority compare functor. No default functor is provided.
                 If the option is not specified, the \p opt::less is used.
             - \p opt::less - specifies binary predicate used for priority compare. Default is \p std::less<T>.
-            - \p opt::lock_type - lock type. Default is \p cds::lock::Spin.
+            - \p opt::lock_type - lock type. Default is \p cds::sync::spin.
             - \p opt::back_off - back-off strategy. Default is \p cds::backoff::yield
             - \p opt::allocator - allocator (like \p std::allocator) for the values of queue's items.
                 Default is \ref CDS_DEFAULT_ALLOCATOR
index 55185f811e1954b58b80f005c473918f39f99050..1ecdcf7a5744f0a71fa77948a762a2da91c8535c 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <mutex>        // unique_lock
 #include <cds/container/msqueue.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace cds { namespace container {
     /// RWQueue related definitions
@@ -16,7 +16,7 @@ namespace cds { namespace container {
         struct traits
         {
             /// Lock policy
-            typedef cds::lock::Spin  lock_type;
+            typedef cds::sync::spin  lock_type;
 
             /// Node allocator
             typedef CDS_DEFAULT_ALLOCATOR   allocator;
@@ -31,7 +31,7 @@ namespace cds { namespace container {
         /// Metafunction converting option list to \p rwqueue::traits
         /**
             Supported \p Options are:
-            - opt::lock_type - lock policy, default is \p cds::lock::Spin. Any type satisfied \p Mutex C++ concept may be used.
+            - opt::lock_type - lock policy, default is \p cds::sync::spin. Any type satisfied \p Mutex C++ concept may be used.
             - opt::allocator - allocator (like \p std::allocator) used for allocating queue nodes. Default is \ref CDS_DEFAULT_ALLOCATOR
             - opt::item_counter - the type of item counting feature. Default is \p cds::atomicity::empty_item_counter (item counting disabled)
                 To enable item counting use \p cds::atomicity::item_counter.
index 69361eecd08a3b9f9e46dbb484d2d0423a37cd71..3fc05271e94dab13c0f987f1b4fa96acdc7edd0a 100644 (file)
@@ -55,7 +55,7 @@ namespace cds { namespace container {
             typedef CDS_DEFAULT_ALLOCATOR allocator;
 
             /// Lock type used to maintain an internal list of allocated segments
-            typedef cds::lock::Spin lock_type;
+            typedef cds::sync::spin lock_type;
 
             /// Random \ref cds::opt::permutation_generator "permutation generator" for sequence [0, quasi_factor)
             typedef cds::opt::v::random2_permutation<int>    permutation_generator;
index d79e1f5beb162e437b8ad62532bdd09d12a9063a..1f8c93f28a9f40084ea08081850a180bb673fa4f 100644 (file)
@@ -69,8 +69,8 @@ namespace cds { namespace container {
             /// Random engine to generate a random position in elimination array
             typedef opt::v::c_rand  random_engine;
 
-            /// Lock type used in elimination, default is cds::lock::Spin
-            typedef cds::lock::Spin lock_type;
+            /// Lock type used in elimination, default is cds::sync::spin
+            typedef cds::sync::spin lock_type;
 
             ///@}
         };
@@ -97,7 +97,7 @@ namespace cds { namespace container {
             - opt::random_engine - a random engine to generate a random position in elimination array.
                 Default is \p opt::v::c_rand.
             - opt::elimination_backoff - back-off strategy to wait for elimination, default is \p cds::backoff::delay<>
-            - opt::lock_type - a lock type used in elimination back-off, default is \p cds::lock::Spin.
+            - opt::lock_type - a lock type used in elimination back-off, default is \p cds::sync::spin.
 
             Example: declare %TreiberStack with item counting and internal statistics using \p %make_traits
             \code
index 58981ef9ff8aefb3ddc00a93784d2470e1eba312..9931e7d7428657bdb0bf84752244b8f39bfb4a46 100644 (file)
@@ -8,7 +8,7 @@
 #include <cds/gc/details/retired_ptr.h>
 #include <cds/details/aligned_allocator.h>
 #include <cds/details/allocator.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 #if CDS_COMPILER == CDS_COMPILER_MSVC
 #   pragma warning(push)
@@ -96,9 +96,9 @@ namespace cds { namespace gc {
             {
                 cds::details::Allocator<details::guard_data>  m_GuardAllocator    ;   ///< guard allocator
 
-                atomics::atomic<guard_data *>    m_GuardList ;       ///< Head of allocated guard list (linked by guard_data::pGlobalNext field)
-                atomics::atomic<guard_data *>    m_FreeGuardList ;   ///< Head of free guard list (linked by guard_data::pNextFree field)
-                SpinLock                m_freeListLock  ;   ///< Access to m_FreeGuardList
+                atomics::atomic<guard_data *>  m_GuardList;     ///< Head of allocated guard list (linked by guard_data::pGlobalNext field)
+                atomics::atomic<guard_data *>  m_FreeGuardList; ///< Head of free guard list (linked by guard_data::pNextFree field)
+                cds::sync::spin                m_freeListLock;  ///< Access to m_FreeGuardList
 
                 /*
                     Unfortunately, access to the list of free guard is lock-based.
@@ -151,7 +151,7 @@ namespace cds { namespace gc {
                     details::guard_data * pGuard;
 
                     {
-                        std::unique_lock<SpinLock> al( m_freeListLock );
+                        std::unique_lock<cds::sync::spin> 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 );
@@ -171,7 +171,7 @@ namespace cds { namespace gc {
                 {
                     pGuard->pPost.store( nullptr, atomics::memory_order_relaxed );
 
-                    std::unique_lock<SpinLock> al( m_freeListLock );
+                    std::unique_lock<cds::sync::spin> 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 );
                 }
@@ -223,7 +223,7 @@ namespace cds { namespace gc {
                         pLast = p;
                     }
 
-                    std::unique_lock<SpinLock> al( m_freeListLock );
+                    std::unique_lock<cds::sync::spin> 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 );
                 }
index c4be8d7ab9d31c983b069b7874bc57f5c06184c7..ab65aa2fe9a43fa4374203e19c0897a3877473ff 100644 (file)
@@ -12,7 +12,7 @@
 #include <cds/opt/hash.h>
 #include <cds/lock/array.h>
 #include <cds/os/thread.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 
 namespace cds { namespace intrusive {
@@ -648,7 +648,7 @@ namespace cds { namespace intrusive {
             typedef unsigned long long  owner_t;
             typedef cds::OS::ThreadId   threadId_t;
 
-            typedef cds::lock::Spin     spinlock_type;
+            typedef cds::sync::spin     spinlock_type;
             typedef std::unique_lock< spinlock_type > scoped_spinlock;
             //@endcond
 
index c83393423b84d7e0a75ce2ef07b8056a30dc25e3..26b9ef95b9e6438a817a26a3287ec8855ce8e792 100644 (file)
@@ -7,7 +7,7 @@
 #include <cds/opt/compare.h>
 #include <cds/details/marked_ptr.h>
 #include <cds/details/make_const_type.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <cds/urcu/options.h>
 
 namespace cds { namespace intrusive {
@@ -20,12 +20,12 @@ namespace cds { namespace intrusive {
         /**
             Template parameters:
             - GC - garbage collector
-            - Lock - lock type. Default is \p cds::lock::Spin
+            - Lock - lock type. Default is \p cds::sync::spin
             - Tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template <
             class GC
-            ,typename Lock =  cds::lock::Spin
+            ,typename Lock =  cds::sync::spin
             ,typename Tag = opt::none
         >
         struct node
@@ -68,7 +68,7 @@ namespace cds { namespace intrusive {
         struct default_hook {
             typedef undefined_gc    gc;
             typedef opt::none       tag;
-            typedef lock::Spin      lock_type;
+            typedef sync::spin      lock_type;
         };
         //@endcond
 
@@ -89,7 +89,7 @@ namespace cds { namespace intrusive {
         /**
             \p Options are:
             - opt::gc - garbage collector
-            - opt::lock_type - lock type used for node locking. Default is lock::Spin
+            - opt::lock_type - lock type used for node locking. Default is sync::spin
             - opt::tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template < typename... Options >
@@ -103,7 +103,7 @@ namespace cds { namespace intrusive {
 
             \p Options are:
             - opt::gc - garbage collector
-            - opt::lock_type - lock type used for node locking. Default is lock::Spin
+            - opt::lock_type - lock type used for node locking. Default is sync::spin
             - opt::tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template < size_t MemberOffset, typename... Options >
@@ -121,7 +121,7 @@ namespace cds { namespace intrusive {
 
             \p Options are:
             - opt::gc - garbage collector used.
-            - opt::lock_type - lock type used for node locking. Default is lock::Spin
+            - opt::lock_type - lock type used for node locking. Default is sync::spin
             - opt::tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template <typename NodeTraits, typename... Options >
index f076b63e6bf7969ffe175569993aeb0ea4213bc1..7cd811365846814bc9a46b2c2dd721120eadbad8 100644 (file)
@@ -53,7 +53,7 @@ namespace cds { namespace intrusive {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::lock_type - mutex type, default is \p cds::lock::Spin
+            - \p opt::lock_type - mutex type, default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy, defalt is \p cds::backoff::Default
             - \p opt::disposer - the functor used for dispose removed items. Default is \p opt::intrusive::v::empty_disposer.
                 This option is used only in \p FCQueue::clear() function.
index b372a4d9d07f7f5d3d2a0ce0f4df376ddf59273c..7e9a00868dd050e1064f039391e21a0ec963ce05 100644 (file)
@@ -53,7 +53,7 @@ namespace cds { namespace intrusive {
         /// Metafunction converting option list to traits
         /**
             \p Options are:
-            - \p opt::lock_type - mutex type, default is \p cds::lock::Spin
+            - \p opt::lock_type - mutex type, default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy, defalt is \p cds::backoff::Default
             - \p opt::disposer - the functor used for dispose removed items. Default is \p opt::intrusive::v::empty_disposer.
                 This option is used only in \p FCStack::clear() function.
index 12d82851a43a51c8820257a071982012b53aef16..c4456be31710c6f67ed52c465b1998cff239f8da 100644 (file)
@@ -12,12 +12,12 @@ namespace cds { namespace intrusive {
         /// Lazy list node for \p gc::nogc
         /**
             Template parameters:
-             - Lock - lock type. Default is \p cds::lock::Spin
+             - Lock - lock type. Default is \p cds::sync::spin
              - Tag - a \ref cds_intrusive_hook_tag "tag"
         */
         template <
 #ifdef CDS_DOXYGEN_INVOKED
-            typename Lock = cds::lock::Spin,
+            typename Lock = cds::sync::spin,
             typename Tag = opt::none
 #else
             typename Lock,
index eca32914b3e9355f6a5b763e96842adb67638e54..405d38e36d0bbfb9fd234edf0ec79dacea2033e7 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <mutex>  // std::unique_lock
 #include <cds/intrusive/details/base.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <cds/os/thread.h>
 #include <cds/details/bit_reverse_counter.h>
 #include <cds/intrusive/options.h>
@@ -70,16 +70,16 @@ namespace cds { namespace intrusive {
             /**
                 No default functor is provided. If the option is not specified, the \p less is used.
             */
-            typedef opt::none           compare;
+            typedef opt::none       compare;
 
             /// Specifies binary predicate used for priority comparing.
             /**
                 Default is \p std::less<T>.
             */
-            typedef opt::none           less;
+            typedef opt::none       less;
 
             /// Type of mutual-exclusion lock
-            typedef lock::Spin          lock_type;
+            typedef cds::sync::spin lock_type;
 
             /// Back-off strategy
             typedef backoff::yield      back_off;
@@ -102,7 +102,7 @@ namespace cds { namespace intrusive {
             - \p opt::compare - priority compare functor. No default functor is provided.
                 If the option is not specified, the \p opt::less is used.
             - \p opt::less - specifies binary predicate used for priority compare. Default is \p std::less<T>.
-            - \p opt::lock_type - lock type. Default is \p cds::lock::Spin.
+            - \p opt::lock_type - lock type. Default is \p cds::sync::spin
             - \p opt::back_off - back-off strategy. Default is \p cds::backoff::yield
             - \p opt::stat - internal statistics. Available types: \p mspriority_queue::stat, \p mspriority_queue::empty_stat (the default, no overhead)
         */
index d10ab14b27e0b986b4cdeb83d3781c91a1875a4d..b4913e95a0185d7cb85f04124abc2842f745cbeb 100644 (file)
@@ -7,7 +7,7 @@
 #include <cds/intrusive/details/base.h>
 #include <cds/details/marked_ptr.h>
 #include <cds/algo/int_algo.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <cds/opt/permutation.h>
 
 #include <boost/intrusive/slist.hpp>
@@ -105,7 +105,7 @@ namespace cds { namespace intrusive {
             typedef CDS_DEFAULT_ALLOCATOR allocator;
 
             /// Lock type used to maintain an internal list of allocated segments
-            typedef cds::lock::Spin lock_type;
+            typedef cds::sync::spin lock_type;
 
             /// Random \ref cds::opt::permutation_generator "permutation generator" for sequence [0, quasi_factor)
             typedef cds::opt::v::random2_permutation<int>    permutation_generator;
index 8404bde9db1062017d984112bd74e510ee6fb8a5..c0f9d80733fbf658736e6c68199ea26e75036472 100644 (file)
@@ -7,7 +7,7 @@
 #include <mutex>
 #include <cds/lock/array.h>
 #include <cds/os/thread.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace cds { namespace intrusive { namespace striped_set {
 
@@ -144,7 +144,7 @@ namespace cds { namespace intrusive { namespace striped_set {
         typedef unsigned long long  owner_t;
         typedef cds::OS::ThreadId   threadId_t;
 
-        typedef cds::lock::Spin     spinlock_type;
+        typedef cds::sync::spin     spinlock_type;
         typedef std::unique_lock< spinlock_type > scoped_spinlock;
         //@endcond
 
index 9ccaa87e6b02fd4f7ba9046f0d761cb6d5318289..d4ee4e3ba6ea9cf1b404f4b700a60480125e90ad 100644 (file)
@@ -8,7 +8,7 @@
 #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/sync/spinlock.h>
 #include <cds/details/type_padding.h>
 
 namespace cds { namespace intrusive {
@@ -199,8 +199,8 @@ namespace cds { namespace intrusive {
             /// Random engine to generate a random position in elimination array
             typedef opt::v::c_rand  random_engine;
 
-            /// Lock type used in elimination, default is cds::lock::Spin
-            typedef cds::lock::Spin lock_type;
+            /// Lock type used in elimination, default is cds::sync::spin
+            typedef cds::sync::spin lock_type;
 
             ///@}
         };
@@ -231,7 +231,7 @@ namespace cds { namespace intrusive {
             - opt::random_engine - a random engine to generate a random position in elimination array.
                 Default is \p opt::v::c_rand.
             - opt::elimination_backoff - back-off strategy to wait for elimination, default is \p cds::backoff::delay<>
-            - opt::lock_type - a lock type used in elimination back-off, default is \p cds::lock::Spin.
+            - opt::lock_type - a lock type used in elimination back-off, default is \p cds::sync::spin
 
             Example: declare \p %TreiberStack with elimination enabled and internal statistics
             \code
index 7901ebbbcbb60b36b81504813059c7aa31d295ed..4842582ab76235580079271bb54a097c61634120 100644 (file)
@@ -92,7 +92,7 @@ namespace cds { namespace lock {
         can be simultaneous.
 
         Template arguments:
-        - \p Lock - lock type, for example, \p std::mutex, \p cds::lock::Spinlock
+        - \p Lock - lock type, for example, \p std::mutex, \p cds::sync::spin_lock
         - \p SelectPolicy - array cell selection policy, the default is \ref mod_select_policy
              Available policies: \ref trivial_select_policy, \ref pow2_select_policy, \ref mod_select_policy.
         - \p Alloc - memory allocator for array
index e9db002bb4832b96b312f34a02856e8670638702..ee6ad258ce3b888ea8697c0cf0968aa6ef28f475 100644 (file)
 #ifndef __CDS_LOCK_SPINLOCK_H
 #define __CDS_LOCK_SPINLOCK_H
 
-/*
-    Defines spin-lock primitives
-    Editions:
-        2012.01.23  1.1.0 khizmax     Refactoring: use C++11 atomics
-        2010.01.22  0.6.0 khizmax     Refactoring: use cds::atomic namespace
-                                      Explicit memory ordering specification (atomic::memory_order_xxx)
-        2006              khizmax     Created
-*/
+#warning "cds/lock/spinlock.h is deprecated, use cds/sync/spinlock.h instead"
 
-#include <cds/algo/atomic.h>
-#include <cds/os/thread.h>
-#include <cds/algo/backoff_strategy.h>
+#include <cds/sync/spinlock.h>
 
+//@cond
 namespace cds {
-    /// Synchronization primitives
+    /// Synchronization primitives (deprecated namespace, use \p cds::sync namespace instead)
     namespace lock {
-        /// Spin lock.
-        /**
-            Simple and light-weight spin-lock critical section
-            It is useful to gain access to small (short-timed) code
 
-            Algorithm:
-
-                TATAS (test-and-test-and-lock)
-                [1984] L. Rudolph, Z. Segall. Dynamic Decentralized Cache Schemes for MIMD Parallel Processors.
-
-            No serialization performed - any of waiting threads may owns the spin-lock.
-            This spin-lock is NOT recursive: the thread owned the lock cannot call lock() method withod deadlock.
-            The method unlock() can call any thread
-
-            DEBUG version: The spinlock stores owner thead id. Assertion is raised when:
-                - double lock attempt encountered by same thread (deadlock)
-                - unlock by another thread
-
-            If spin-lock is locked the Backoff algorithm is called. Predefined backoff::LockDefault class yields current
-            thread and repeats lock attempts later
-
-            Template parameters:
-                - @p Backoff    backoff strategy. Used when spin lock is locked
-        */
-        template <typename Backoff >
-        class Spinlock
-        {
-        public:
-            typedef        Backoff      backoff_strategy    ;        ///< back-off strategy type
-        private:
-            atomics::atomic<bool>    m_spin  ;       ///< Spin
-#    ifdef CDS_DEBUG
-            typename OS::ThreadId    m_dbgOwnerId        ;       ///< Owner thread id (only for debug mode)
-#    endif
-
-        public:
-            /// Construct free (unlocked) spin-lock
-            Spinlock() CDS_NOEXCEPT
-#    ifdef CDS_DEBUG
-                :m_dbgOwnerId( OS::c_NullThreadId )
-#    endif
-            {
-                m_spin.store( false, atomics::memory_order_relaxed );
-            }
-
-            /// Construct spin-lock in specified state
-            /**
-                In debug mode: if \p bLocked = true then spin-lock is made owned by current thread
-            */
-            Spinlock( bool bLocked ) CDS_NOEXCEPT
-#    ifdef CDS_DEBUG
-                : m_dbgOwnerId( bLocked ? OS::get_current_thread_id() : OS::c_NullThreadId )
-#    endif
-            {
-                m_spin.store( bLocked, atomics::memory_order_relaxed );
-            }
-
-            /// Dummy copy constructor
-            /**
-                In theory, spin-lock cannot be copied. However, it is not practical.
-                Therefore, we provide dummy copy constructor that do no copy in fact. The ctor
-                initializes the spin to free (unlocked) state like default ctor.
-            */
-            Spinlock(const Spinlock<Backoff>& ) CDS_NOEXCEPT
-                : m_spin( false )
-#   ifdef CDS_DEBUG
-                , m_dbgOwnerId( OS::c_NullThreadId )
-#   endif
-            {}
-
-            /// Destructor. On debug time it checks whether spin-lock is free
-            ~Spinlock()
-            {
-                assert( !m_spin.load( atomics::memory_order_relaxed ) );
-            }
-
-            /// Check if the spin is locked
-            bool is_locked() const CDS_NOEXCEPT
-            {
-                return m_spin.load( atomics::memory_order_relaxed );
-            }
-
-            /// Try to lock the object
-            /**
-                Returns \p true if locking is succeeded
-                otherwise (if the spin is already locked) returns \p false
-
-                Debug version: deadlock can be detected
-            */
-            bool try_lock() CDS_NOEXCEPT
-            {
-                bool bCurrent = false;
-                m_spin.compare_exchange_strong( bCurrent, true, atomics::memory_order_acquire, atomics::memory_order_relaxed );
-
-                CDS_DEBUG_ONLY(
-                    if ( !bCurrent ) {
-                        m_dbgOwnerId = OS::get_current_thread_id();
-                    }
-                )
-                return !bCurrent;
-            }
-
-            /// Try to lock the object, repeat @p nTryCount times if failed
-            /**
-                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()() ) )
-            {
-                backoff_strategy backoff;
-                while ( nTryCount-- ) {
-                    if ( try_lock() )
-                        return true;
-                    backoff();
-                }
-                return false;
-            }
-
-            /// Lock the spin-lock. Waits infinitely while spin-lock is locked. Debug version: deadlock may be detected
-            void lock() CDS_NOEXCEPT_(noexcept( backoff_strategy()() ))
-            {
-                backoff_strategy backoff;
-
-                // Deadlock detected
-                assert( m_dbgOwnerId != OS::get_current_thread_id() );
-
-                // TATAS algorithm
-                while ( !try_lock() ) {
-                    while ( m_spin.load( atomics::memory_order_relaxed ) ) {
-                        backoff();
-                    }
-                }
-                assert( m_dbgOwnerId == OS::get_current_thread_id() );
-            }
-
-            /// Unlock the spin-lock. Debug version: deadlock may be detected
-            void unlock() CDS_NOEXCEPT
-            {
-                assert( m_spin.load( atomics::memory_order_relaxed ) );
-
-                assert( m_dbgOwnerId == OS::get_current_thread_id() );
-                CDS_DEBUG_ONLY( m_dbgOwnerId = OS::c_NullThreadId; )
-
-                m_spin.store( false, atomics::memory_order_release );
-            }
-        };
+        /// Alias for \p cds::sync::spin_lock for backward compatibility
+        template <typename Backoff>
+        using Spinlock = cds::sync::spin_lock< Backoff >;
 
         /// Spin-lock implementation default for the current platform
-        typedef Spinlock<backoff::LockDefault >                 Spin;
+        typedef cds::sync::spin_lock< backoff::LockDefault> Spin;
 
-        /// Recursive spin lock.
-        /**
-            Allows recursive calls: the owner thread may recursive enter to critical section guarded by the spin-lock.
-
-            Template parameters:
-                - @p Integral       one of integral atomic type: <tt>unsigned int</tt>, <tt>int</tt>, and others
-                - @p Backoff        backoff strategy. Used when spin lock is locked
-        */
+        /// Alias for \p cds::sync::reentrant_spin_lock for backward compatibility
         template <typename Integral, class Backoff>
-        class ReentrantSpinT
-        {
-            typedef OS::ThreadId    thread_id    ;        ///< The type of thread id
-
-        public:
-            typedef Integral        integral_type       ; ///< The integral type
-            typedef Backoff         backoff_strategy    ; ///< The backoff type
-
-        private:
-            atomics::atomic<integral_type>   m_spin      ; ///< spin-lock atomic
-            thread_id                        m_OwnerId   ; ///< Owner thread id. If spin-lock is not locked it usually equals to OS::c_NullThreadId
-
-        private:
-            //@cond
-            void take( thread_id tid ) CDS_NOEXCEPT
-            {
-                m_OwnerId = tid;
-            }
-
-            void free() CDS_NOEXCEPT
-            {
-                m_OwnerId = OS::c_NullThreadId;
-            }
-
-            bool is_taken( thread_id tid ) const CDS_NOEXCEPT
-            {
-                return m_OwnerId == tid;
-            }
-
-            bool try_taken_lock( thread_id tid ) CDS_NOEXCEPT
-            {
-                if ( is_taken( tid )) {
-                    m_spin.fetch_add( 1, atomics::memory_order_relaxed );
-                    return true;
-                }
-                return false;
-            }
-
-            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 );
-            }
-
-            bool try_acquire( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()() ))
-            {
-                backoff_strategy bkoff;
-
-                while ( nTryCount-- ) {
-                    if ( try_acquire() )
-                        return true;
-                    bkoff();
-                }
-                return false;
-            }
-
-            void acquire() CDS_NOEXCEPT_( noexcept( backoff_strategy()() ))
-            {
-                // TATAS algorithm
-                backoff_strategy bkoff;
-                while ( !try_acquire() ) {
-                    while ( m_spin.load( atomics::memory_order_relaxed ) )
-                        bkoff();
-                }
-            }
-            //@endcond
-
-        public:
-            /// Default constructor initializes spin to free (unlocked) state
-            ReentrantSpinT() CDS_NOEXCEPT
-                : m_spin(0)
-                , m_OwnerId( OS::c_NullThreadId )
-            {}
-
-            /// Dummy copy constructor
-            /**
-                In theory, spin-lock cannot be copied. However, it is not practical.
-                Therefore, we provide dummy copy constructor that do no copy in fact. The ctor
-                initializes the spin to free (unlocked) state like default ctor.
-            */
-            ReentrantSpinT(const ReentrantSpinT<Integral, Backoff>& ) CDS_NOEXCEPT
-                : m_spin(0)
-                , m_OwnerId( OS::c_NullThreadId )
-            {}
-
-            /// Construct object for specified state
-            ReentrantSpinT(bool bLocked) CDS_NOEXCEPT
-                : m_spin(0)
-                , m_OwnerId( OS::c_NullThreadId )
-            {
-                if ( bLocked )
-                    lock();
-            }
-
-            /// Checks if the spin is locked
-            /**
-                The spin is locked if lock count > 0 and the current thread is not an owner of the lock.
-                Otherwise (i.e. lock count == 0 or the curren thread owns the spin) the spin is unlocked.
-            */
-            bool is_locked() const CDS_NOEXCEPT
-            {
-                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::get_current_thread_id();
-                if ( try_taken_lock( tid ) )
-                    return true;
-                if ( try_acquire()) {
-                    take( tid );
-                    return true;
-                }
-                return false;
-            }
-
-            /// Try to lock the object
-            bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( try_acquire( nTryCount ) ) )
-            {
-                thread_id tid = OS::get_current_thread_id();
-                if ( try_taken_lock( tid ) )
-                    return true;
-                if ( try_acquire( nTryCount )) {
-                    take( tid );
-                    return true;
-                }
-                return false;
-            }
-
-            /// Lock the object waits if it is busy
-            void lock() CDS_NOEXCEPT
-            {
-                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::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 );
-                    else {
-                        free();
-                        m_spin.store( 0, atomics::memory_order_release );
-                    }
-                    return true;
-                }
-                return false;
-            }
-
-            /// 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() ) ) {
-                    assert( newOwnerId != OS::c_NullThreadId );
-                    m_OwnerId = newOwnerId;
-                    return true;
-                }
-                return false;
-            }
-        };
+        using ReentrantSpinT = cds::sync::reentrant_spin_lock< Integral, Backoff >;
 
         /// Recursive 32bit spin-lock
-        typedef ReentrantSpinT<uint32_t, backoff::LockDefault> ReentrantSpin32;
+        typedef cds::sync::reentrant_spin32 ReentrantSpin32;
 
         /// Recursive 64bit spin-lock
-        typedef ReentrantSpinT<uint64_t, backoff::LockDefault> ReentrantSpin64;
+        typedef cds::sync::reentrant_spin64 ReentrantSpin64;
 
         /// Default recursive spin-lock type
         typedef ReentrantSpin32 ReentrantSpin;
@@ -370,5 +47,6 @@ namespace cds {
     typedef lock::ReentrantSpin64   RecursiveSpinLock64;
 
 } // namespace cds
+//@endcond
 
 #endif  // #ifndef __CDS_LOCK_SPINLOCK_H
index 08a738a3cea3f8d6690e22c809ddb218a571666b..bc30dd1fa01a69ac2bd8aa533ca62d9423adbe3e 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <cds/os/topology.h>
 #include <cds/os/alloc_aligned.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <cds/details/type_padding.h>
 #include <cds/details/marked_ptr.h>
 #include <cds/container/vyukov_mpmc_cycle_queue.h>
@@ -703,8 +703,8 @@ namespace michael {
             typedef page_cached_allocator<>     page_heap;
             typedef aligned_malloc_heap         aligned_heap;
             typedef default_sizeclass_selector  sizeclass_selector;
-            typedef free_list_locked<cds::lock::Spin>  free_list;
-            typedef partial_list_locked<cds::lock::Spin>    partial_list;
+            typedef free_list_locked<cds::sync::spin>    free_list;
+            typedef partial_list_locked<cds::sync::spin> partial_list;
             typedef procheap_empty_stat         procheap_stat;
             typedef os_allocated_empty          os_allocated_stat;
             typedef cds::opt::none              check_bounds;
index 7b9c3d854ddb46ea6c3bd07b5906a41dd50e9240..6645adaf544213c44245554a5e790a2992d952fc 100644 (file)
@@ -50,11 +50,11 @@ namespace opt {
 
         Examples:
         \code
-        // default_spin is cds::lock::Spin
-        typedef typename cds::opt::select_default< cds::opt::none, cds::lock::Spin >::type  default_spin;
+        // default_spin is cds::sync::spin
+        typedef typename cds::opt::select_default< cds::opt::none, cds::sync::spin >::type  default_spin;
 
-        // spin_32bit is cds::lock::Spin32
-        typedef typename cds::opt::select_default< cds::lock::Spin32, cds::lock::Spin >::type  spin_32bit;
+        // spin_32bit is cds::sync::reentrant_spin32
+        typedef typename cds::opt::select_default< cds::lock::Spin32, cds::sync::reentrant_spin32 >::type  spin_32bit;
         \endcode
     */
     template <typename Option, typename Default, typename Value = Option>
diff --git a/cds/sync/injected_monitor.h b/cds/sync/injected_monitor.h
new file mode 100644 (file)
index 0000000..4626e7c
--- /dev/null
@@ -0,0 +1,68 @@
+//$$CDS-header$$
+
+#ifndef CDSLIB_LOCK_INJECTED_MONITOR_H
+#define CDSLIB_LOCK_INJECTED_MONITOR_H
+
+namespace cds { namespace lock {
+
+    /// Monitor that injects a lock as a member into a class
+    /**
+        Template arguments:
+        - Lock - lock type like \p std::mutex or \p cds::sync::spin
+    */
+    template <typename Lock>
+    class injected_monitor
+    {
+    public:
+        typedef Lock lock_type;
+
+        template <typename T>
+        struct wrapper : public T
+        {
+            using T::T;
+            mutable lock_type m_Lock;
+
+            void lock() const
+            {
+                m_Lock.lock;
+            }
+
+            void unlock() const
+            {
+                m_Lock.unlock();
+            }
+        };
+
+        template <typename T>
+        void lock( T const& p ) const
+        {
+            p.lock();
+        }
+
+        template <typename T>
+        void unlock( T const& p ) const
+        {
+            p.unlock();
+        }
+
+        template <typename T>
+        class scoped_lock
+        {
+            T const& m_Locked;
+
+        public:
+            scoped_lock( injected_monitor const&, T const& p )
+                : m_Locked( p )
+            {
+                p.lock();
+            }
+
+            ~scoped_lock()
+            {
+                p.unlock();
+            }
+        };
+    };
+}} // namespace cds::lock
+
+#endif // #ifndef CDSLIB_LOCK_INJECTED_MONITOR_H
diff --git a/cds/sync/spinlock.h b/cds/sync/spinlock.h
new file mode 100644 (file)
index 0000000..753fe07
--- /dev/null
@@ -0,0 +1,351 @@
+//$$CDS-header$$-2
+
+#ifndef CDSLIB_SYNC_SPINLOCK_H
+#define CDSLIB_SYNC_SPINLOCK_H
+
+#include <cds/algo/atomic.h>
+#include <cds/os/thread.h>
+#include <cds/algo/backoff_strategy.h>
+
+namespace cds {
+    /// Synchronization primitives
+    namespace sync {
+        /// Spin lock
+        /**
+            Simple and light-weight spin-lock critical section
+            It is useful to gain access to small (short-timed) code
+
+            Algorithm:
+
+                TATAS (test-and-test-and-lock)
+                [1984] L. Rudolph, Z. Segall. Dynamic Decentralized Cache Schemes for MIMD Parallel Processors.
+
+            No serialization performed - any of waiting threads may owns the spin-lock.
+            This spin-lock is NOT recursive: the thread owned the lock cannot call lock() method withod deadlock.
+            The method unlock() can call any thread
+
+            DEBUG version: The spinlock stores owner thead id. Assertion is raised when:
+                - double lock attempt encountered by same thread (deadlock)
+                - unlock by another thread
+
+            If spin-lock is locked the Backoff algorithm is called. Predefined backoff::LockDefault class yields current
+            thread and repeats lock attempts later
+
+            Template parameters:
+                - @p Backoff    backoff strategy. Used when spin lock is locked
+        */
+        template <typename Backoff >
+        class spin_lock
+        {
+        public:
+            typedef Backoff backoff_strategy;   ///< back-off strategy type
+        private:
+            atomics::atomic<bool>    m_spin;    ///< Spin
+#    ifdef CDS_DEBUG
+            typename OS::ThreadId    m_dbgOwnerId; ///< Owner thread id (only for debug mode)
+#    endif
+
+        public:
+            /// Construct free (unlocked) spin-lock
+            spin_lock() CDS_NOEXCEPT
+#    ifdef CDS_DEBUG
+                :m_dbgOwnerId( OS::c_NullThreadId )
+#    endif
+            {
+                m_spin.store( false, atomics::memory_order_relaxed );
+            }
+
+            /// Construct spin-lock in specified state
+            /**
+                In debug mode: if \p bLocked = true then spin-lock is made owned by current thread
+            */
+            spin_lock( bool bLocked ) CDS_NOEXCEPT
+#    ifdef CDS_DEBUG
+                : m_dbgOwnerId( bLocked ? cds::OS::get_current_thread_id() : cds::OS::c_NullThreadId )
+#    endif
+            {
+                m_spin.store( bLocked, atomics::memory_order_relaxed );
+            }
+
+            /// Dummy copy constructor
+            /**
+                In theory, spin-lock cannot be copied. However, it is not practical.
+                Therefore, we provide dummy copy constructor that do no copy in fact. The ctor
+                initializes the spin to free (unlocked) state like default ctor.
+            */
+            spin_lock(const spin_lock<Backoff>& ) CDS_NOEXCEPT
+                : m_spin( false )
+#   ifdef CDS_DEBUG
+                , m_dbgOwnerId( cds::OS::c_NullThreadId )
+#   endif
+            {}
+
+            /// Destructor. On debug time it checks whether spin-lock is free
+            ~spin_lock()
+            {
+                assert( !m_spin.load( atomics::memory_order_relaxed ) );
+            }
+
+            /// Check if the spin is locked
+            bool is_locked() const CDS_NOEXCEPT
+            {
+                return m_spin.load( atomics::memory_order_relaxed );
+            }
+
+            /// Try to lock the object
+            /**
+                Returns \p true if locking is succeeded
+                otherwise (if the spin is already locked) returns \p false
+
+                Debug version: deadlock can be detected
+            */
+            bool try_lock() CDS_NOEXCEPT
+            {
+                bool bCurrent = false;
+                m_spin.compare_exchange_strong( bCurrent, true, atomics::memory_order_acquire, atomics::memory_order_relaxed );
+
+                CDS_DEBUG_ONLY(
+                    if ( !bCurrent ) {
+                        m_dbgOwnerId = OS::get_current_thread_id();
+                    }
+                )
+                return !bCurrent;
+            }
+
+            /// Try to lock the object, repeat @p nTryCount times if failed
+            /**
+                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()() ) )
+            {
+                backoff_strategy backoff;
+                while ( nTryCount-- ) {
+                    if ( try_lock() )
+                        return true;
+                    backoff();
+                }
+                return false;
+            }
+
+            /// Lock the spin-lock. Waits infinitely while spin-lock is locked. Debug version: deadlock may be detected
+            void lock() CDS_NOEXCEPT_(noexcept( backoff_strategy()() ))
+            {
+                backoff_strategy backoff;
+
+                // Deadlock detected
+                assert( m_dbgOwnerId != OS::get_current_thread_id() );
+
+                // TATAS algorithm
+                while ( !try_lock() ) {
+                    while ( m_spin.load( atomics::memory_order_relaxed ) ) {
+                        backoff();
+                    }
+                }
+                assert( m_dbgOwnerId == OS::get_current_thread_id() );
+            }
+
+            /// Unlock the spin-lock. Debug version: deadlock may be detected
+            void unlock() CDS_NOEXCEPT
+            {
+                assert( m_spin.load( atomics::memory_order_relaxed ) );
+
+                assert( m_dbgOwnerId == OS::get_current_thread_id() );
+                CDS_DEBUG_ONLY( m_dbgOwnerId = OS::c_NullThreadId; )
+
+                m_spin.store( false, atomics::memory_order_release );
+            }
+        };
+
+        /// Spin-lock implementation default for the current platform
+        typedef spin_lock<backoff::LockDefault > spin;
+
+        /// Recursive spin lock.
+        /**
+            Allows recursive calls: the owner thread may recursive enter to critical section guarded by the spin-lock.
+
+            Template parameters:
+                - @p Integral       one of integral atomic type: <tt>unsigned int</tt>, <tt>int</tt>, and others
+                - @p Backoff        backoff strategy. Used when spin lock is locked
+        */
+        template <typename Integral, class Backoff>
+        class reentrant_spin_lock
+        {
+            typedef OS::ThreadId    thread_id    ;        ///< The type of thread id
+
+        public:
+            typedef Integral        integral_type       ; ///< The integral type
+            typedef Backoff         backoff_strategy    ; ///< The backoff type
+
+        private:
+            atomics::atomic<integral_type>   m_spin      ; ///< spin-lock atomic
+            thread_id                        m_OwnerId   ; ///< Owner thread id. If spin-lock is not locked it usually equals to OS::c_NullThreadId
+
+        private:
+            //@cond
+            void take( thread_id tid ) CDS_NOEXCEPT
+            {
+                m_OwnerId = tid;
+            }
+
+            void free() CDS_NOEXCEPT
+            {
+                m_OwnerId = OS::c_NullThreadId;
+            }
+
+            bool is_taken( thread_id tid ) const CDS_NOEXCEPT
+            {
+                return m_OwnerId == tid;
+            }
+
+            bool try_taken_lock( thread_id tid ) CDS_NOEXCEPT
+            {
+                if ( is_taken( tid )) {
+                    m_spin.fetch_add( 1, atomics::memory_order_relaxed );
+                    return true;
+                }
+                return false;
+            }
+
+            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 );
+            }
+
+            bool try_acquire( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()() ))
+            {
+                backoff_strategy bkoff;
+
+                while ( nTryCount-- ) {
+                    if ( try_acquire() )
+                        return true;
+                    bkoff();
+                }
+                return false;
+            }
+
+            void acquire() CDS_NOEXCEPT_( noexcept( backoff_strategy()() ))
+            {
+                // TATAS algorithm
+                backoff_strategy bkoff;
+                while ( !try_acquire() ) {
+                    while ( m_spin.load( atomics::memory_order_relaxed ) )
+                        bkoff();
+                }
+            }
+            //@endcond
+
+        public:
+            /// Default constructor initializes spin to free (unlocked) state
+            reentrant_spin_lock() CDS_NOEXCEPT
+                : m_spin(0)
+                , m_OwnerId( OS::c_NullThreadId )
+            {}
+
+            /// Dummy copy constructor
+            /**
+                In theory, spin-lock cannot be copied. However, it is not practical.
+                Therefore, we provide dummy copy constructor that do no copy in fact. The ctor
+                initializes the spin to free (unlocked) state like default ctor.
+            */
+            reentrant_spin_lock( const reentrant_spin_lock<Integral, Backoff>& ) CDS_NOEXCEPT
+                : m_spin(0)
+                , m_OwnerId( OS::c_NullThreadId )
+            {}
+
+            /// Construct object for specified state
+            reentrant_spin_lock( bool bLocked ) CDS_NOEXCEPT
+                : m_spin(0)
+                , m_OwnerId( OS::c_NullThreadId )
+            {
+                if ( bLocked )
+                    lock();
+            }
+
+            /// Checks if the spin is locked
+            /**
+                The spin is locked if lock count > 0 and the current thread is not an owner of the lock.
+                Otherwise (i.e. lock count == 0 or the curren thread owns the spin) the spin is unlocked.
+            */
+            bool is_locked() const CDS_NOEXCEPT
+            {
+                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::get_current_thread_id();
+                if ( try_taken_lock( tid ) )
+                    return true;
+                if ( try_acquire()) {
+                    take( tid );
+                    return true;
+                }
+                return false;
+            }
+
+            /// Try to lock the object
+            bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( try_acquire( nTryCount ) ) )
+            {
+                thread_id tid = OS::get_current_thread_id();
+                if ( try_taken_lock( tid ) )
+                    return true;
+                if ( try_acquire( nTryCount )) {
+                    take( tid );
+                    return true;
+                }
+                return false;
+            }
+
+            /// Lock the object waits if it is busy
+            void lock() CDS_NOEXCEPT
+            {
+                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::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 );
+                    else {
+                        free();
+                        m_spin.store( 0, atomics::memory_order_release );
+                    }
+                    return true;
+                }
+                return false;
+            }
+
+            /// 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() ) ) {
+                    assert( newOwnerId != OS::c_NullThreadId );
+                    m_OwnerId = newOwnerId;
+                    return true;
+                }
+                return false;
+            }
+        };
+
+        /// Recursive 32bit spin-lock
+        typedef reentrant_spin_lock<uint32_t, backoff::LockDefault> reentrant_spin32;
+
+        /// Default recursive spin-lock
+        typedef reentrant_spin32 reentrant_spin;
+
+        /// Recursive 64bit spin-lock
+        typedef reentrant_spin_lock<uint64_t, backoff::LockDefault> reentrant_spin64;
+    }    // namespace sync
+} // namespace cds
+
+#endif  // #ifndef CDSLIB_SYNC_SPINLOCK_H
index 3aebf3a1e93f6e7f8d708c2e15e13a8cdbd03cd3..a986993956cfa9694490baa8f8c3bf9651bc0426 100644 (file)
@@ -1,5 +1,8 @@
 2.1.0
-    TODO
+    - cds::lock namespace is renamed to cds::sync. All classes defined in cds::lock namespace 
+      are moved to cds::sync with new names (for example, cds::lock::SpinLock is renamed to
+      cds::sync::spin_lock). cds::lock namespace and its contents is deprecated and it is kept 
+      for backward compatibility.
 
 2.0.0 30.12.2014
     General release
index 3dd82f60dd7ea95cb9ef4fef4105be250804475c..0bdfd121b7f7c2a9359b54bfb782990b9702e4b8 100644 (file)
     <ClInclude Include="..\..\..\cds\os\osx\topology.h" />\r
     <ClInclude Include="..\..\..\cds\os\posix\fake_topology.h" />\r
     <ClInclude Include="..\..\..\cds\os\posix\timer.h" />\r
+    <ClInclude Include="..\..\..\cds\sync\injected_monitor.h" />\r
+    <ClInclude Include="..\..\..\cds\sync\spinlock.h" />\r
     <ClInclude Include="..\..\..\cds\threading\details\cxx11.h" />\r
     <ClInclude Include="..\..\..\cds\threading\details\cxx11_manager.h" />\r
     <ClInclude Include="..\..\..\cds\urcu\details\base.h" />\r
index 6b52bf201f1f9ecf7553fcdcfc45ac024f577bb2..5cbefad17e22faf3a5a5eeffb4e95a4354764359 100644 (file)
     <Filter Include="Header Files\cds\gc\impl">\r
       <UniqueIdentifier>{3195cce2-1710-4b79-a1cf-6c7cea085fa3}</UniqueIdentifier>\r
     </Filter>\r
+    <Filter Include="Header Files\cds\sync">\r
+      <UniqueIdentifier>{03d212fb-73f8-4f0e-9aff-f22b0783fee8}</UniqueIdentifier>\r
+    </Filter>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="..\..\..\src\dllmain.cpp">\r
     <ClInclude Include="..\..\..\cds\algo\atomic.h">\r
       <Filter>Header Files\cds\algo</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\..\cds\sync\injected_monitor.h">\r
+      <Filter>Header Files\cds\sync</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="..\..\..\cds\sync\spinlock.h">\r
+      <Filter>Header Files\cds\sync</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index 146fde5780e80a0932174b5cc248eafbef68147a..60a981ad057e0c90fe0a6e32f4a37c8ebcb02a27 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_flat_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -63,7 +63,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< map_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            ,co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index 4668c6bebd5a7bb0c9adf73bc6c63e19957d0658..d2f31c1e96c7ad871390bda047be20d7b2686714 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_list.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -63,7 +63,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            ,co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index 350ec6257ddda0641df7e6e551597d92359eac84..49a2afaf4c81f1e8e2f3660741f023bc236c059d 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -63,7 +63,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< map_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            ,co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index 1e18fb968c076e81f65a4fe973c7db29bdb1af36..b96eb81eba02d10f2f735d07124c7dded99faa2b 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/boost_unordered_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -50,7 +50,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< map_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index d3e06c03000d1d6af3236a3ff5589cd477e28ee9..047f47897b5759fa67095d922e8728debf58c6cc 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/std_hash_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 #if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
 
@@ -52,7 +52,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< map_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index a8ff667e6330595bef1bbc17ea88cca39e3878ea..33f031a95a2214fd9be3f44fcc77aabd6d00b13a 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/std_list.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -50,7 +50,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index 93adb93927ada116809f9f636a93ed3fc97ef728..c98b2f7ce758e8312dc5ee519c6cb98bdf86b437 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/std_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -50,7 +50,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< map_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index 48d5f7178154de0bc1a8ae2ef5e1bfa0d5e2f133..e0aaa6d6d03d7b0d76412dab813987e39dc887a4 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_slist.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 
 namespace map {
@@ -64,7 +64,7 @@ namespace map {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedMap< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::spin> >
             , co::hash< hash_int >
             , co::less< less >
         >   map_spin;
index 842c500b920d22bb7fcd852b9a9c38bc817c0b10..69c700dbafd5ce592944b4667b17748bc2fa1f21 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_flat_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -63,7 +63,7 @@ namespace map {
         typedef cc::StripedMap< map_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped< map_spin >();
 
index a33e1fbcff11ef938ecd190da0579ef9abf3974a..ec562543d2b3d7c92b2961bca7c36f08128e0373 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_list.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -63,7 +63,7 @@ namespace map {
         typedef cc::StripedMap< sequence_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped2< map_spin >();
 
index a808999635c05cc42e2555bc486e8c75f4b28687..39e2852692fecb6f41983b0b1cd0fe99353fc6d1 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -63,7 +63,7 @@ namespace map {
         typedef cc::StripedMap< map_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped< map_spin >();
 
index 412fca1474a665f02ff9ce638b038e4c76740560..9437b80a336e0f475a2003385549668f6dabfc02 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/boost_unordered_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -50,7 +50,7 @@ namespace map {
         typedef cc::StripedMap< map_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped< map_spin >();
 
index 95ca72211fd4effb2ea10730a65f9c6a6ed5cf56..dd933a3881827d857315d390ad21eb92f363f60d 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/std_hash_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 #if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
 
@@ -52,7 +52,7 @@ namespace map {
         typedef cc::StripedMap< map_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped< map_spin >();
 
index b71ede2455d3860f52120f5ff9cec37ae3351e8d..2cd2f4879baec30a715cabd4bd6fb0585af0bc1e 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/std_list.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -51,7 +51,7 @@ namespace map {
         typedef cc::StripedMap< sequence_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped2< map_spin >();
 
index 1a3e479415bff83e57d82853e0ce83f087c0125a..a990221891f635175103a3745bd0bd90d41c5276 100644 (file)
@@ -3,7 +3,7 @@
 #include "map/hdr_striped_map.h"
 #include <cds/container/striped_map/std_map.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -50,7 +50,7 @@ namespace map {
         typedef cc::StripedMap< map_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped< map_spin >();
 
index 170faaa872eb80c0c8d2dabb5d885e4328a8055f..309f1db6721a2d639c5daa0cfcc82bced59e2a41 100644 (file)
@@ -16,7 +16,7 @@ namespace map {
 
 #include <cds/container/striped_map/boost_slist.h>
 #include <cds/container/striped_map.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace map {
 
@@ -63,7 +63,7 @@ namespace map {
         typedef cc::StripedMap< sequence_t
             , co::hash< hash_int >
             , co::less< less >
-            ,co::mutex_policy< cc::striped_set::striping<cds::lock::Spin> >
+            , co::mutex_policy< cc::striped_set::striping<cds::sync::spin> >
         >   map_spin;
         test_striped2< map_spin >();
 
index 4fa1ddb557762406532702eb2d61e811229dc31f..374942c10d8e6dad76cb948fd5ee413dbda68cb9 100644 (file)
@@ -17,7 +17,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_flat_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -64,7 +64,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< set_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index f00128144101ca1ad13f8644720a39bb92361102..4f56162e788ce6006eb3fd7dfaef1ae95405d2fb 100644 (file)
@@ -16,7 +16,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_list.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -64,7 +64,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index b0cb72943fb64ed66b2bc219a27ccf57312ce991..e268434b57755999142a3073b86a8cc41f91cf59 100644 (file)
@@ -16,7 +16,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -63,7 +63,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< set_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index c6dfd908ebdefe953f78a4f500b6b20088818cf3..5d3d316a227fa1e768ba423bd57a8a2ff22acd7a 100644 (file)
@@ -17,7 +17,7 @@ namespace set {
 #include <cds/details/defs.h>
 #include <cds/container/striped_set/boost_stable_vector.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -65,7 +65,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index 42713b99da8c3e83328cbd3c06a83a43ed024111..042a2fc65b640ba2c4d34c4ad6c4af9865062748 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/boost_unordered_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -59,7 +59,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< set_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index e006c73de380da96e9335bf1d68729a32e08dc25..3983c1243f7fc8e94aadc15e9a0f30c60d5d8554 100644 (file)
@@ -18,7 +18,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_vector.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -66,7 +66,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index 9d7d1ac151747a45fd7edbadacbf436a167573b4..aa367105d619ba26ab3a4d314bbcbdf38b20dcd6 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_hash_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 #if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
 
@@ -61,7 +61,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< set_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index cdba942345aad1ce99be05eb31ee2e2783dc2f1d..e5ba93bae05f6e9294aa8deb07119e4483a4e300 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_list.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -51,7 +51,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index 7acf7ad46d2e6c5a78e5f99c541838cd00a77344..94139bf7f8245b0e7775a94006748e4052a8ca11 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -51,7 +51,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< set_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index 23499c8f1f761324f87d770b330ffa37956e7151..be9772edb43e6f6f9504b396a48489e10fc9de87 100644 (file)
@@ -15,7 +15,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_slist.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -63,7 +63,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index bd912994e4d94b9d67677dfc2f997a02d5242ef0..0622c14d81bfccc17b47d20a9f38703632d26b44 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_vector.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -51,7 +51,7 @@ namespace set {
         // Spinlock as lock policy
         CPPUNIT_MESSAGE( "spinlock");
         typedef cc::StripedSet< sequence_t
-            ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
+            , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
             , co::hash< hash_int >
             , co::less< less<item> >
         >   set_spin;
index eaaf0c79b33f55c8ab91af8ce4925470fb10cc7e..f004f2bae1c39fde7ab974b0ee4989b898c4c5b4 100644 (file)
@@ -16,7 +16,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_flat_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -63,7 +63,7 @@ namespace set {
         typedef cc::StripedSet< set_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            ,co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped< set_spin >();
 
index 79521064b2e9bfb06a7859e9e60681a48273d431..b8faaffc7017821e35f35be1616bb03a2b5f85a1 100644 (file)
@@ -16,7 +16,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_list.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -62,7 +62,7 @@ namespace set {
         typedef cc::StripedSet< sequence_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped2< set_spin >();
 
index 4006e357b1de6b32ed09616476a5940409d8882e..8c2a8883b451b2086991a300f354cad67280b3ca 100644 (file)
@@ -16,7 +16,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -65,7 +65,7 @@ namespace set {
         typedef cc::StripedSet< set_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped< set_spin >();
 
index b1e9bc66401cbb8ad0987bc4f9d5012ee3a3588b..7fbdb6086a6fb1e2fbd9065e27d58d82243d1fc3 100644 (file)
@@ -17,7 +17,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_stable_vector.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -67,7 +67,7 @@ namespace set {
         typedef cc::StripedSet< sequence_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped2< set_spin >();
 
index cad515b78c1c11ed27b508eb730784473dba2826..5262e01295bc25bb5ef8aee949b5645333bada70 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/boost_unordered_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -61,7 +61,7 @@ namespace set {
         typedef cc::StripedSet< set_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped< set_spin >();
 
index ef0b9f918d0d4c32cd75ea14cd9cdf1c1bedde1b..38f13d15b49116d41052bc262117820071796c80 100644 (file)
@@ -16,7 +16,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_vector.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -66,7 +66,7 @@ namespace set {
         typedef cc::StripedSet< sequence_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped2< set_spin >();
 
index 9f75a3c362a5e9a2e51cccfcb8b5f2b983a0ee72..405276756570394470e9804b2c8ff6aa7fa706f1 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_hash_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 #if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
 
@@ -63,7 +63,7 @@ namespace set {
         typedef cc::StripedSet< set_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped< set_spin >();
 
index 432b5513e84f27aee59d3769b0760f0c0df0d4f6..9b2e30bbfbc46490c2fe2663ed112480f1835825 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_list.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -53,7 +53,7 @@ namespace set {
         typedef cc::StripedSet< sequence_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped2< set_spin >();
 
index 5a58a39091765891c0c2db14f6af349755ad0ca9..4df0f9be43402f5ef3a85072a5d82e6e3af14c2f 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_set.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -53,7 +53,7 @@ namespace set {
         typedef cc::StripedSet< set_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped< set_spin >();
 
index 68637a39a224737fd18532d42793f77cfc490728..73ea1d413261e0b5f2704d1d9eff615ff83c6879 100644 (file)
@@ -15,7 +15,7 @@ namespace set {
 
 #include <cds/container/striped_set/boost_slist.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -65,7 +65,7 @@ namespace set {
         typedef cc::StripedSet< sequence_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped2< set_spin >();
 
index 4fda502c59325f6b107d0516bac12796f42094a2..ea8100c8bc31a97ad5d5b39e6551e7132dadbdb1 100644 (file)
@@ -3,7 +3,7 @@
 #include "set/hdr_striped_set.h"
 #include <cds/container/striped_set/std_vector.h>
 #include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set {
 
@@ -53,7 +53,7 @@ namespace set {
         typedef cc::StripedSet< sequence_t
             , co::hash< hash_int >
             , co::less< less<item> >
-            ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
+            , co::mutex_policy< cc::striped_set::striping< cds::sync::spin> >
         >   set_spin;
         test_striped2< set_spin >();
 
index 3e6a6b416c124710211acb4d5ba9a47a7382706d..9a60d83a8ed6a34215de4e287da65deef8906827 100644 (file)
@@ -22,7 +22,7 @@ namespace memory {
     static size_t s_nPassPerThread;
 
     struct Item {
-        cds::SpinLock   m_access;
+        cds::sync::spin m_access;
         char *          m_pszBlock;
 
         Item()
index bfaae2b374b9c74daf92483ea5245f07a78ded4a..aabbdb6f03a918bac18281fb6b1af77650be2c63 100644 (file)
@@ -93,21 +93,25 @@ namespace lock {
             }
         }
 
-        typedef cds::lock::Spinlock<cds::backoff::exponential<cds::backoff::hint, cds::backoff::yield> > Spinlock_exp;
+        typedef cds::sync::spin_lock<cds::backoff::exponential<cds::backoff::hint, cds::backoff::yield> > Spinlock_exp;
 
-        typedef cds::lock::ReentrantSpinT<unsigned int, cds::backoff::exponential<cds::backoff::hint, cds::backoff::yield> > reentrantSpin_exp;
-        typedef cds::lock::ReentrantSpinT<unsigned int, cds::backoff::yield> reentrantSpin_yield;
-        typedef cds::lock::ReentrantSpinT<unsigned int, cds::backoff::hint> reentrantSpin_hint;
-        typedef cds::lock::ReentrantSpinT<unsigned int, cds::backoff::empty> reentrantSpin_empty;
+        typedef cds::sync::reentrant_spin_lock<unsigned int, cds::backoff::exponential<cds::backoff::hint, cds::backoff::yield> > reentrantSpin_exp;
+        typedef cds::sync::reentrant_spin_lock<unsigned int, cds::backoff::yield> reentrantSpin_yield;
+        typedef cds::sync::reentrant_spin_lock<unsigned int, cds::backoff::hint> reentrantSpin_hint;
+        typedef cds::sync::reentrant_spin_lock<unsigned int, cds::backoff::empty> reentrantSpin_empty;
 
         TEST_CASE(spinLock_exp,         Spinlock_exp );
-        TEST_CASE(spinLock_yield,       cds::lock::Spinlock<cds::backoff::yield> );
-        TEST_CASE(spinLock_hint,        cds::lock::Spinlock<cds::backoff::hint> );
-        TEST_CASE(spinLock_empty,       cds::lock::Spinlock<cds::backoff::empty> );
-
-        TEST_CASE(reentrantSpinLock,    cds::lock::ReentrantSpin    );
-        TEST_CASE(reentrantSpinLock32,  cds::lock::ReentrantSpin32  );
-        TEST_CASE(reentrantSpinLock64,  cds::lock::ReentrantSpin64  );
+        TEST_CASE(spinLock_yield,       cds::sync::spin_lock<cds::backoff::yield> );
+        TEST_CASE(spinLock_hint,        cds::sync::spin_lock<cds::backoff::hint> );
+        TEST_CASE(spinLock_empty,       cds::sync::spin_lock<cds::backoff::empty> );
+        TEST_CASE( spinLock_yield_lock, cds::lock::Spinlock<cds::backoff::yield> );
+        TEST_CASE( spinLock_hint_lock, cds::lock::Spinlock<cds::backoff::hint> );
+        TEST_CASE( spinLock_empty_lock, cds::lock::Spinlock<cds::backoff::empty> );
+
+        TEST_CASE( reentrantSpinLock32, cds::sync::reentrant_spin32 );
+        TEST_CASE( reentrantSpinLock64, cds::sync::reentrant_spin64 );
+        TEST_CASE( reentrantSpinLock32_lock, cds::lock::ReentrantSpin32 );
+        TEST_CASE( reentrantSpinLock64_lock, cds::lock::ReentrantSpin64 );
 
         TEST_CASE(reentrantSpinlock_exp,        reentrantSpin_exp );
         TEST_CASE(reentrantSpinlock_yield,      reentrantSpin_yield );
@@ -121,7 +125,6 @@ namespace lock {
             CPPUNIT_TEST(spinLock_hint);
             CPPUNIT_TEST(spinLock_empty);
 
-            CPPUNIT_TEST(reentrantSpinLock);
             CPPUNIT_TEST(reentrantSpinLock32);
             CPPUNIT_TEST(reentrantSpinLock64);
 
index aa09a1dd726394b659aec552e16dc84d0899274c..365f2de773724ffc6073dfa313a4ffac0b4d7449 100644 (file)
@@ -5,7 +5,7 @@
 #include "map2/map_types.h"
 #include "cppunit/thread.h"
 
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <vector>
 #include <algorithm>    // random_shuffle
 
@@ -36,7 +36,7 @@ namespace map2 {
             atomics::atomic<bool>   bInitialized;
             cds::OS::ThreadId          threadId     ;   // insert thread id
 
-            typedef cds::lock::Spinlock< cds::backoff::pause >   lock_type;
+            typedef cds::sync::spin_lock< cds::backoff::pause > lock_type;
             mutable lock_type   m_access;
 
             value_type()
index 8a4c99a0043a4b344ad63f0f6837cced72126630..ff63de4eabe6079648c47f56af0ec258d1f6129c 100644 (file)
@@ -51,7 +51,7 @@
 #include <cds/container/striped_map/boost_unordered_map.h>
 #include <cds/container/striped_map.h>
 
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 #include "cppunit/cppunit_mini.h"
 #include "lock/nolock.h"
@@ -1717,11 +1717,11 @@ namespace map2 {
         // ***************************************************************************
         // Standard implementations
 
-        typedef StdMap< Key, Value, cds::SpinLock >             StdMap_Spin;
-        typedef StdMap< Key, Value, lock::NoLock>               StdMap_NoLock;
+        typedef StdMap< Key, Value, cds::sync::spin >     StdMap_Spin;
+        typedef StdMap< Key, Value, lock::NoLock>         StdMap_NoLock;
 
-        typedef StdHashMap< Key, Value, cds::SpinLock >         StdHashMap_Spin;
-        typedef StdHashMap< Key, Value, lock::NoLock >          StdHashMap_NoLock;
+        typedef StdHashMap< Key, Value, cds::sync::spin > StdHashMap_Spin;
+        typedef StdHashMap< Key, Value, lock::NoLock >    StdHashMap_NoLock;
 
     };
 
index 5c90614069aa7e1f0cf30c199ceb30fdf678eb61..fa8c9c4296eea23f4aa4ea2eb06e74e4979c4e82 100644 (file)
@@ -14,7 +14,7 @@
 #include <deque>
 #include <boost/container/stable_vector.hpp>
 #include <boost/container/deque.hpp>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 #include "print_ellenbintree_stat.h"
 #include "print_skip_list_stat.h"
@@ -280,9 +280,9 @@ namespace pqueue {
         > FCPQueue_boost_stable_vector_stat;
 
         /// Standard priority_queue
-        typedef StdPQueue< Value, std::vector<Value>, cds::lock::Spin > StdPQueue_vector_spin;
+        typedef StdPQueue< Value, std::vector<Value>, cds::sync::spin> StdPQueue_vector_spin;
         typedef StdPQueue< Value, std::vector<Value>, std::mutex >  StdPQueue_vector_mutex;
-        typedef StdPQueue< Value, std::deque<Value>,  cds::lock::Spin > StdPQueue_deque_spin;
+        typedef StdPQueue< Value, std::deque<Value>, cds::sync::spin> StdPQueue_deque_spin;
         typedef StdPQueue< Value, std::deque<Value>,  std::mutex >  StdPQueue_deque_mutex;
     };
 
index 97605ae35471289975ac00a80f34d8c53cb5d3f7..d62ad233a289fd74492cfd13201b60e5b1e43d60 100644 (file)
@@ -463,8 +463,8 @@ namespace queue {
         typedef cds::intrusive::SegmentedQueue< cds::gc::DHP, T, traits_SegmentedQueue_mutex_stat >  SegmentedQueue_DHP_mutex_stat;
 
         // Boost SList
-        typedef details::BoostSList< T, std::mutex >    BoostSList_mutex;
-        typedef details::BoostSList< T, cds::lock::Spin >   BoostSList_spin;
+        typedef details::BoostSList< T, std::mutex >      BoostSList_mutex;
+        typedef details::BoostSList< T, cds::sync::spin > BoostSList_spin;
     };
 }
 
index 42935e36326e49c7607b18f16aca29b72b7198a2..5848ddc19e5170db20db465d9a48786f71688f86 100644 (file)
@@ -5,11 +5,11 @@
 
 #include <mutex>    //unique_lock
 #include <queue>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace queue {
 
-    template <typename T, class Container, class Lock = cds::lock::Spin >
+    template <typename T, class Container, class Lock = cds::sync::spin >
     class StdQueue: public std::queue<T, Container >
     {
         typedef std::queue<T, Container >   base_class;
@@ -42,11 +42,11 @@ namespace queue {
         }
     };
 
-    template <typename T, class Lock = cds::lock::Spin >
+    template <typename T, class Lock = cds::sync::spin >
     class StdQueue_deque: public StdQueue<T, std::deque<T>, Lock >
     {};
 
-    template <typename T, class Lock = cds::lock::Spin >
+    template <typename T, class Lock = cds::sync::spin >
     class StdQueue_list: public StdQueue<T, std::list<T>, Lock >
     {};
 }
index 6c75a97cd4a2b48bd6ef22720142acfd5c8a80b5..4d38066a40e472506b1094538755342881d0e679 100644 (file)
@@ -7,7 +7,7 @@
 #include "set2/set_types.h"
 #include "cppunit/thread.h"
 
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 
 namespace set2 {
 
@@ -34,7 +34,7 @@ namespace set2 {
             bool volatile   bInitialized;
             cds::OS::ThreadId          threadId     ;   // insert thread id
 
-            typedef cds::lock::Spinlock< cds::backoff::pause >   lock_type;
+            typedef cds::sync::spin_lock< cds::backoff::pause > lock_type;
             mutable lock_type   m_access;
 
             value_type()
index ea0c63cd1a92cebb7b5f1cc385712df2f4a547e0..a048eb3791122dfe1f4929d0ca62bd79da4bc033 100644 (file)
@@ -49,7 +49,7 @@
 #endif
 #include <cds/container/striped_set.h>
 
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <boost/functional/hash/hash.hpp>
 
 #include "cppunit/cppunit_mini.h"
@@ -1709,11 +1709,11 @@ namespace set2 {
         // ***************************************************************************
         // Standard implementations
 
-        typedef StdSet< key_val, less, cds::SpinLock >                  StdSet_Spin;
-        typedef StdSet< key_val, less, lock::NoLock>                    StdSet_NoLock;
+        typedef StdSet< key_val, less, cds::sync::spin > StdSet_Spin;
+        typedef StdSet< key_val, less, lock::NoLock>     StdSet_NoLock;
 
-        typedef StdHashSet< key_val, hash, less, equal_to, cds::SpinLock >    StdHashSet_Spin;
-        typedef StdHashSet< key_val, hash, less, equal_to, lock::NoLock >     StdHashSet_NoLock;
+        typedef StdHashSet< key_val, hash, less, equal_to, cds::sync::spin > StdHashSet_Spin;
+        typedef StdHashSet< key_val, hash, less, equal_to, lock::NoLock >    StdHashSet_NoLock;
 
     };
 
index 9898180d35729ebcaadea85f131b28ed28a141c8..cf447e1b37380924a240b4ff381425ff2729e5a4 100644 (file)
@@ -10,7 +10,7 @@
 #include <cds/gc/dhp.h>
 
 #include <mutex>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <stack>
 #include <list>
 #include <vector>
@@ -337,11 +337,11 @@ namespace istack {
 
         // std::stack
         typedef details::StdStack< T, std::stack< T* >, std::mutex >  StdStack_Deque_Mutex;
-        typedef details::StdStack< T, std::stack< T* >, cds::lock::Spin > StdStack_Deque_Spin;
+        typedef details::StdStack< T, std::stack< T* >, cds::sync::spin > StdStack_Deque_Spin;
         typedef details::StdStack< T, std::stack< T*, std::vector<T*> >, std::mutex >  StdStack_Vector_Mutex;
-        typedef details::StdStack< T, std::stack< T*, std::vector<T*> >, cds::lock::Spin > StdStack_Vector_Spin;
+        typedef details::StdStack< T, std::stack< T*, std::vector<T*> >, cds::sync::spin > StdStack_Vector_Spin;
         typedef details::StdStack< T, std::stack< T*, std::list<T*> >, std::mutex >  StdStack_List_Mutex;
-        typedef details::StdStack< T, std::stack< T*, std::list<T*> >, cds::lock::Spin > StdStack_List_Spin;
+        typedef details::StdStack< T, std::stack< T*, std::list<T*> >, cds::sync::spin > StdStack_List_Spin;
 
     };
 } // namespace istack
index e27622b673478b9268eea4d0232c59fb9d746db7..076a88ce3c9c16a8af6ba2309d4c0b291d24cfcc 100644 (file)
@@ -11,7 +11,7 @@
 #include <cds/gc/dhp.h>
 
 #include <mutex>
-#include <cds/lock/spinlock.h>
+#include <cds/sync/spinlock.h>
 #include <stack>
 #include <list>
 #include <vector>
@@ -383,11 +383,11 @@ namespace stack {
 
         // std::stack
         typedef details::StdStack< T, std::stack< T >, std::mutex >  StdStack_Deque_Mutex;
-        typedef details::StdStack< T, std::stack< T >, cds::lock::Spin > StdStack_Deque_Spin;
+        typedef details::StdStack< T, std::stack< T >, cds::sync::spin > StdStack_Deque_Spin;
         typedef details::StdStack< T, std::stack< T, std::vector<T> >, std::mutex >  StdStack_Vector_Mutex;
-        typedef details::StdStack< T, std::stack< T, std::vector<T> >, cds::lock::Spin > StdStack_Vector_Spin;
+        typedef details::StdStack< T, std::stack< T, std::vector<T> >, cds::sync::spin > StdStack_Vector_Spin;
         typedef details::StdStack< T, std::stack< T, std::list<T> >, std::mutex >  StdStack_List_Mutex;
-        typedef details::StdStack< T, std::stack< T, std::list<T> >, cds::lock::Spin > StdStack_List_Spin;
+        typedef details::StdStack< T, std::stack< T, std::list<T> >, cds::sync::spin > StdStack_List_Spin;
 
     };
 } // namespace stack