3 #ifndef __CDS_UNIT_ELLEN_BINTREE_UPDATE_DESC_POOL_H
4 #define __CDS_UNIT_ELLEN_BINTREE_UPDATE_DESC_POOL_H
6 #include <cds/urcu/general_instant.h>
7 #include <cds/container/ellen_bintree_base.h>
8 #include <cds/memory/vyukov_queue_pool.h>
9 #include <cds/memory/pool_allocator.h>
11 namespace ellen_bintree_pool {
12 typedef cds::container::ellen_bintree::node_types< cds::urcu::gc< cds::urcu::general_instant<> >, int > node_types ; // fake
13 typedef node_types::leaf_node_type leaf_node;
14 typedef node_types::internal_node_type internal_node;
15 typedef node_types::update_desc_type update_desc;
17 // Update descriptor pool based on Vyukov's queue
18 typedef cds::memory::vyukov_queue_pool<
20 cds::opt::buffer< cds::opt::v::static_buffer< cds::any_type, 4096 > >
21 > update_desc_pool_type;
23 extern update_desc_pool_type s_UpdateDescPool;
25 struct update_desc_pool_accessor {
26 typedef update_desc_pool_type::value_type value_type;
28 update_desc_pool_type& operator()() const
30 return s_UpdateDescPool;
34 // Update descriptor pool based on bounded Vyukov's queue
35 typedef cds::memory::bounded_vyukov_queue_pool<
37 cds::opt::buffer< cds::opt::v::static_buffer< cds::any_type, 4096 > >
38 > bounded_update_desc_pool_type;
40 extern bounded_update_desc_pool_type s_BoundedUpdateDescPool;
42 struct bounded_update_desc_pool_accessor {
43 typedef bounded_update_desc_pool_type::value_type value_type;
45 bounded_update_desc_pool_type& operator()() const
47 return s_BoundedUpdateDescPool;
52 // Internal node allocator
53 struct internal_node_counter
55 static cds::atomicity::event_counter m_nAlloc;
56 static cds::atomicity::event_counter m_nFree;
74 template <typename T, typename Alloc = CDS_DEFAULT_ALLOCATOR>
75 class internal_node_allocator
76 : public Alloc::template rebind< T >::other
77 , internal_node_counter
79 typedef typename Alloc::template rebind< T >::other base_class;
81 template <typename Other>
83 typedef internal_node_allocator< Other, Alloc > other;
86 T * allocate( size_t n, void const * pHint = NULL )
88 internal_node_counter::onAlloc();
89 return base_class::allocate( n, pHint );
92 void deallocate( T * p, size_t n )
94 internal_node_counter::onFree();
95 return base_class::deallocate( p, n );
99 } // namespace ellen_bintree_pool
101 #endif // #ifndef __CDS_UNIT_ELLEN_BINTREE_UPDATE_DESC_POOL_H