From: khizmax Date: Tue, 12 Apr 2016 14:08:37 +0000 (+0300) Subject: Added update desc pool to intrusive EllenBinTree unit test X-Git-Tag: v2.2.0~281 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=4b42dc318cfcfff8eb865c902d8bebf25a25b12e Added update desc pool to intrusive EllenBinTree unit test --- diff --git a/test/unit/tree/intrusive_ellenbintree_dhp.cpp b/test/unit/tree/intrusive_ellenbintree_dhp.cpp index 58a82134..f5b3b1a2 100644 --- a/test/unit/tree/intrusive_ellenbintree_dhp.cpp +++ b/test/unit/tree/intrusive_ellenbintree_dhp.cpp @@ -31,8 +31,8 @@ #include "test_intrusive_tree_hp.h" #include -//#include -//#include +#include +#include namespace { namespace ci = cds::intrusive; @@ -54,6 +54,56 @@ namespace { typedef ci::ellen_bintree::internal_node< key_type, member_item_type > internal_member_node; typedef ci::ellen_bintree::update_desc< member_item_type, internal_member_node > update_member_desc; + // update_desc pools + struct pool_traits: public cds::memory::vyukov_queue_pool_traits + { + typedef cds::opt::v::static_buffer< update_base_desc, 256 > buffer; + }; + typedef cds::memory::vyukov_queue_pool< update_base_desc, pool_traits > pool_type; + typedef cds::memory::lazy_vyukov_queue_pool< update_base_desc, pool_traits > lazy_pool_type; + + static pool_type * s_Pool; + static lazy_pool_type * s_LazyPool; + + struct pool_accessor + { + typedef pool_type::value_type value_type; + + pool_type& operator()() const + { + return *s_Pool; + } + }; + + struct lazy_pool_accessor + { + typedef lazy_pool_type::value_type value_type; + + lazy_pool_type& operator()() const + { + return *s_LazyPool; + } + }; + + static void SetUpTestCase() + { + ASSERT_TRUE( s_Pool == nullptr ); + ASSERT_TRUE( s_LazyPool == nullptr ); + s_Pool = new pool_type; + s_LazyPool = new lazy_pool_type; + } + + static void TearDownTestCase() + { + ASSERT_TRUE( s_Pool != nullptr ); + ASSERT_TRUE( s_LazyPool != nullptr ); + delete s_LazyPool; + delete s_Pool; + + s_LazyPool = nullptr; + s_Pool = nullptr; + } + void SetUp() { struct list_traits : public ci::ellen_bintree::traits @@ -79,6 +129,8 @@ namespace { }; }; + /*static*/ IntrusiveEllenBinTree_DHP::pool_type * IntrusiveEllenBinTree_DHP::s_Pool = nullptr; + /*static*/ IntrusiveEllenBinTree_DHP::lazy_pool_type * IntrusiveEllenBinTree_DHP::s_LazyPool = nullptr; TEST_F( IntrusiveEllenBinTree_DHP, base_cmp ) { @@ -158,6 +210,38 @@ namespace { test( t ); } + TEST_F( IntrusiveEllenBinTree_DHP, base_update_desc_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + + TEST_F( IntrusiveEllenBinTree_DHP, base_update_desc_lazy_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + // member hook TEST_F( IntrusiveEllenBinTree_DHP, member_cmp ) { @@ -237,4 +321,36 @@ namespace { test( t ); } + TEST_F( IntrusiveEllenBinTree_DHP, member_update_desc_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, member_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + + TEST_F( IntrusiveEllenBinTree_DHP, member_update_desc_lazy_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, member_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + } // namespace diff --git a/test/unit/tree/intrusive_ellenbintree_hp.cpp b/test/unit/tree/intrusive_ellenbintree_hp.cpp index 9b676f33..384cbc57 100644 --- a/test/unit/tree/intrusive_ellenbintree_hp.cpp +++ b/test/unit/tree/intrusive_ellenbintree_hp.cpp @@ -31,8 +31,8 @@ #include "test_intrusive_tree_hp.h" #include -//#include -//#include +#include +#include namespace { namespace ci = cds::intrusive; @@ -54,6 +54,56 @@ namespace { typedef ci::ellen_bintree::internal_node< key_type, member_item_type > internal_member_node; typedef ci::ellen_bintree::update_desc< member_item_type, internal_member_node > update_member_desc; + // update_desc pools + struct pool_traits: public cds::memory::vyukov_queue_pool_traits + { + typedef cds::opt::v::static_buffer< update_base_desc, 256 > buffer; + }; + typedef cds::memory::vyukov_queue_pool< update_base_desc, pool_traits > pool_type; + typedef cds::memory::lazy_vyukov_queue_pool< update_base_desc, pool_traits > lazy_pool_type; + + static pool_type * s_Pool; + static lazy_pool_type * s_LazyPool; + + struct pool_accessor + { + typedef pool_type::value_type value_type; + + pool_type& operator()() const + { + return *s_Pool; + } + }; + + struct lazy_pool_accessor + { + typedef lazy_pool_type::value_type value_type; + + lazy_pool_type& operator()() const + { + return *s_LazyPool; + } + }; + + static void SetUpTestCase() + { + ASSERT_TRUE( s_Pool == nullptr ); + ASSERT_TRUE( s_LazyPool == nullptr ); + s_Pool = new pool_type; + s_LazyPool = new lazy_pool_type; + } + + static void TearDownTestCase() + { + ASSERT_TRUE( s_Pool != nullptr ); + ASSERT_TRUE( s_LazyPool != nullptr ); + delete s_LazyPool; + delete s_Pool; + + s_LazyPool = nullptr; + s_Pool = nullptr; + } + void SetUp() { struct list_traits : public ci::ellen_bintree::traits @@ -80,6 +130,9 @@ namespace { }; }; + /*static*/ IntrusiveEllenBinTree_HP::pool_type * IntrusiveEllenBinTree_HP::s_Pool = nullptr; + /*static*/ IntrusiveEllenBinTree_HP::lazy_pool_type * IntrusiveEllenBinTree_HP::s_LazyPool = nullptr; + TEST_F( IntrusiveEllenBinTree_HP, base_cmp ) { @@ -159,6 +212,38 @@ namespace { test( t ); } + TEST_F( IntrusiveEllenBinTree_HP, base_update_desc_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + + TEST_F( IntrusiveEllenBinTree_HP, base_update_desc_lazy_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::base_hook< ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, base_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + // member hook TEST_F( IntrusiveEllenBinTree_HP, member_cmp ) { @@ -238,4 +323,36 @@ namespace { test( t ); } + TEST_F( IntrusiveEllenBinTree_HP, member_update_desc_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, member_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + + TEST_F( IntrusiveEllenBinTree_HP, member_update_desc_lazy_pool ) + { + struct tree_traits: public generic_traits + { + typedef ci::ellen_bintree::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook; + typedef base_class::less less; + typedef cds::atomicity::item_counter item_counter; + typedef cds::memory::pool_allocator update_desc_allocator; + }; + + typedef ci::EllenBinTree< gc_type, key_type, member_item_type, tree_traits > tree_type; + + tree_type t; + test( t ); + } + } // namespace