#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 {
/// 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
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()
}
// 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 )
> stack_t;
\endcode
*/
- template <typename GC, typename T, CDS_DECL_OPTIONS13>
+ template <typename GC, typename T, typename... Options>
class TreiberStack
{
//@cond
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: