Replace cds::lock::scoped_lock with std::unique_lock, remove cds/lock/scoped_lock.h
[libcds.git] / cds / intrusive / treiber_stack.h
index 9a580f040ef40e795e45c940c45b66703d17d87f..5e5083c10098fc55e34624495e2b25603d1d26c7 100644 (file)
@@ -4,12 +4,12 @@
 #define __CDS_INTRUSIVE_TREIBER_STACK_H
 
 #include <type_traits>
-#include <cds/intrusive/single_link_struct.h>
-#include <cds/ref.h>
+#include <functional>   // ref
+#include <mutex>        // unique_lock
+#include <cds/intrusive/details/single_link_struct.h>
 #include <cds/algo/elimination.h>
 #include <cds/opt/buffer.h>
 #include <cds/lock/spinlock.h>
-#include <cds/lock/scoped_lock.h>
 #include <cds/details/type_padding.h>
 
 namespace cds { namespace intrusive {
@@ -161,14 +161,6 @@ namespace cds { namespace intrusive {
                 /// Operation descriptor used in elimination back-off
                 typedef treiber_stack::operation< T >  operation_desc;
 
-#           if !(defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10))
-                struct bkoff_predicate {
-                    operation_desc * pOp;
-                    bkoff_predicate( operation_desc * p ): pOp(p) {}
-                    bool operator()() { return pOp->nStatus.load( atomics::memory_order_acquire ) != op_busy; }
-                };
-#           endif
-
                 /// Elimination back-off data
                 struct elimination_data {
                     elimination_random_engine   randEngine; ///< random engine
@@ -191,7 +183,7 @@ namespace cds { namespace intrusive {
                     op_collided = 2
                 };
 
-                typedef cds::lock::scoped_lock< elimination_lock_type > slot_scoped_lock;
+                typedef std::unique_lock< elimination_lock_type > slot_scoped_lock;
 
             public:
                 elimination_backoff()
@@ -243,19 +235,7 @@ namespace cds { namespace intrusive {
                     }
 
                     // Wait for colliding operation
-#               if defined(CDS_CXX11_LAMBDA_SUPPORT) && !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION == CDS_COMPILER_MSVC10)
-                    // MSVC++ 2010 compiler error C2065: 'op_busy' : undeclared identifier
                     bkoff( [&op]() -> bool { return op.nStatus.load( atomics::memory_order_acquire ) != op_busy; } );
-#               else
-                    // Local structs is not supported by old compilers (for example, GCC 4.3)
-                    //struct bkoff_predicate {
-                    //    operation_desc * pOp;
-                    //    bkoff_predicate( operation_desc * p ): pOp(p) {}
-                    //    bool operator()() { return pOp->nStatus.load( atomics::memory_order_acquire ) != op_busy; }
-                    //};
-                    bkoff( bkoff_predicate(&op) );
-#               endif
-
                     {
                         slot_scoped_lock l( slot.lock );
                         if ( slot.pRec == myRec )
@@ -431,7 +411,7 @@ namespace cds { namespace intrusive {
         > stack_t;
         \endcode
     */
-    template <typename GC, typename T, CDS_DECL_OPTIONS13>
+    template <typename GC, typename T, typename... Options>
     class TreiberStack
     {
         //@cond
@@ -457,16 +437,16 @@ namespace cds { namespace intrusive {
     public:
         //@cond
         typedef typename opt::make_options<
-            typename cds::opt::find_type_traits< default_options, CDS_OPTIONS13 >::type
-            ,CDS_OPTIONS13
+            typename cds::opt::find_type_traits< default_options, Options... >::type
+            ,Options...
         >::type   options;
         //@endcond
 
     public:
         /// Rebind template arguments
-        template <typename GC2, typename T2, CDS_DECL_OTHER_OPTIONS13>
+        template <typename GC2, typename T2, typename... Options2>
         struct rebind {
-            typedef TreiberStack< GC2, T2, CDS_OTHER_OPTIONS13> other   ;   ///< Rebinding result
+            typedef TreiberStack< GC2, T2, Options2...> other   ;   ///< Rebinding result
         };
 
     public: