issue #76: added cds::atomicity::cache_friendly_item_counter to avoid false sharing
[libcds.git] / cds / intrusive / details / ellen_bintree_base.h
index a0a8363b6dd5eccfcf949d749c9f6cf589a23f9d..ed03e3b8ca28196aa8df57596503789a432bd18e 100644 (file)
@@ -105,7 +105,7 @@ namespace cds { namespace intrusive {
         };
 
         //@cond
-        struct basic_node
+        struct alignas( void* ) basic_node
         {
             enum flags {
                 internal        = 1,    ///< set for internal node
@@ -119,8 +119,9 @@ namespace cds { namespace intrusive {
 
             /// Constructs leaf (bIntrenal == false) or internal (bInternal == true) node
             explicit basic_node( bool bInternal )
-                : m_nFlags( bInternal ? internal : 0 )
-            {}
+            {
+                m_nFlags.store( bInternal ? internal: 0, atomics::memory_order_release );
+            }
 
             /// Checks if the node is a leaf
             bool is_leaf() const
@@ -168,6 +169,7 @@ namespace cds { namespace intrusive {
             typedef basic_node base_class;
 
             typedef GC              gc       ;   ///< Garbage collector
+
             /// Constructs leaf (bIntrenal == false) or internal (bInternal == true) node
             explicit base_node( bool bInternal )
                 : base_class( bInternal )
@@ -241,8 +243,9 @@ namespace cds { namespace intrusive {
                 , m_pLeft( nullptr )
                 , m_pRight( nullptr )
                 , m_pUpdate( update_ptr())
-                , m_nEmptyUpdate(0)
-            {}
+            {
+                m_nEmptyUpdate.store( 0, atomics::memory_order_release );
+            }
 
             //@cond
             update_ptr null_update_desc()
@@ -512,7 +515,7 @@ namespace cds { namespace intrusive {
             /// Item counter
             /**
                 The type for item counter, by default it is disabled (\p atomicity::empty_item_counter).
-                To enable it use \p atomicity::item_counter
+                To enable it use \p atomicity::item_counter or \p atomicity::cache_friendly_item_counter
             */
             typedef atomicity::empty_item_counter item_counter;
 
@@ -528,9 +531,9 @@ namespace cds { namespace intrusive {
 
                 Update descriptor is helping data structure with short lifetime and it is good candidate
                 for pooling. The number of simultaneously existing descriptors is bounded and it is
-                limited the number of threads working with the tree.
+                limited by number of threads working with the tree.
                 Therefore, a bounded lock-free container like \p cds::container::VyukovMPMCCycleQueue
-                is good choice for the free-list of update descriptors,
+                is good choice for the free-list of update descriptors,
                 see \p cds::memory::vyukov_queue_pool free-list implementation.
 
                 Also notice that size of update descriptor is constant and not dependent on the type of data
@@ -579,7 +582,7 @@ namespace cds { namespace intrusive {
             - \p opt::disposer - the functor used for dispose removed nodes. Default is \p opt::v::empty_disposer. Due the nature
                 of GC schema the disposer may be called asynchronously. The disposer is used only for leaf nodes.
             - \p opt::item_counter - the type of item counting feature, by default it is disabled (\p atomicity::empty_item_counter)
-                To enable it use \p atomicity::item_counter
+                To enable it use \p atomicity::item_counter or \p atomicity::cache_friendly_item_counter
             - \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
                 or \p opt::v::sequential_consistent (sequentially consisnent memory model).
             - \p ellen_bintree::update_desc_allocator - an allocator of \ref ellen_bintree::update_desc "update descriptors",