X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=cds%2Fcontainer%2Fdetails%2Fskip_list_base.h;h=be4e3a508e6dcc1861916d589f5aa72505e173d5;hb=83904aeb6442d3f60c99dd627ac704feeb1b5a82;hp=1b744b9d45d1415fe0db9f1f9434006f54a21214;hpb=2bb66f1d159d044d2c5dad0f0f968abcb6d53287;p=libcds.git diff --git a/cds/container/details/skip_list_base.h b/cds/container/details/skip_list_base.h index 1b744b9d..be4e3a50 100644 --- a/cds/container/details/skip_list_base.h +++ b/cds/container/details/skip_list_base.h @@ -45,10 +45,40 @@ namespace cds { namespace container { using random_level_generator = cds::intrusive::skip_list::random_level_generator; /// Xor-shift random level generator - typedef cds::intrusive::skip_list::xorshift xorshift; + template + using xor_shift = cds::intrusive::skip_list::xor_shift; + + /// Xor-shift random level generator, max height 32 + typedef cds::intrusive::skip_list::xorshift32 xorshift32; + + /// Xor-shift random level generator, max height 24 + typedef cds::intrusive::skip_list::xorshift24 xorshift24; + + /// Xor-shift random level generator, max height 16 + typedef cds::intrusive::skip_list::xorshift16 xorshift16; + + //@cond + // for backward compatibility + using cds::intrusive::skip_list::xorshift; + //@endcond /// Turbo-pascal random level generator - typedef cds::intrusive::skip_list::turbo_pascal turbo_pascal; + template + using turbo = cds::intrusive::skip_list::turbo; + + /// Turbo-pascal random level generator, max height 32 + typedef cds::intrusive::skip_list::turbo32 turbo32; + + /// Turbo-pascal random level generator, max height 24 + typedef cds::intrusive::skip_list::turbo24 turbo24; + + /// Turbo-pascal random level generator, max height 16 + typedef cds::intrusive::skip_list::turbo16 turbo16; + + //@cond + // for backward compatibility + using cds::intrusive::skip_list::turbo_pascal; + //@endcond /// Skip list internal statistics template @@ -94,7 +124,7 @@ namespace cds { namespace container { See \p skip_list::random_level_generator option setter. */ - typedef turbo_pascal random_level_generator; + typedef turbo32 random_level_generator; /// Allocator for skip-list nodes, \p std::allocator interface typedef CDS_DEFAULT_ALLOCATOR allocator; @@ -126,9 +156,8 @@ namespace cds { namespace container { - \p opt::item_counter - the type of item counting feature. Default is \p atomicity::empty_item_counter that is no item counting. - \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 skip_list::random_level_generator - random level generator. Can be \p skip_list::xorshift, \p skip_list::turbo_pascal or - user-provided one. - Default is \p %skip_list::turbo_pascal. + - \p skip_list::random_level_generator - random level generator. Can be \p skip_list::xor_shift, \p skip_list::turbo or + user-provided one. Default is \p %skip_list::turbo32. - \p opt::allocator - allocator for skip-list node. Default is \ref CDS_DEFAULT_ALLOCATOR. - \p opt::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used. - \p opt::stat - internal statistics. Available types: \p skip_list::stat, \p skip_list::empty_stat (the default) @@ -170,23 +199,30 @@ namespace cds { namespace container { { return c_nNodeSize + (nHeight - 1) * c_nTowerItemSize; } + static unsigned char * alloc_space( unsigned int nHeight ) { + unsigned char * pMem; + size_t const sz = node_size( nHeight ); + if ( nHeight > 1 ) { - unsigned char * pMem = tower_allocator_type().allocate( node_size(nHeight)); + pMem = tower_allocator_type().allocate( sz ); // check proper alignments assert( (((uintptr_t) pMem) & (alignof(node_type) - 1)) == 0 ); assert( (((uintptr_t) (pMem + c_nNodeSize)) & (alignof(node_tower_item) - 1)) == 0 ); return pMem; } + else + pMem = reinterpret_cast( node_allocator_type().allocate( 1 )); - return reinterpret_cast( node_allocator_type().allocate(1)); + return pMem; } static void free_space( unsigned char * p, unsigned int nHeight ) { assert( p != nullptr ); + if ( nHeight == 1 ) node_allocator_type().deallocate( reinterpret_cast(p), 1 ); else