Skip to content

Commit

Permalink
Small corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz-Trela committed Feb 7, 2018
1 parent 64dc57d commit ec45dd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
23 changes: 12 additions & 11 deletions libraries/chainbase/include/chainbase/allocators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ namespace chainbase {
#endif

typedef boost::unique_lock< read_write_mutex > write_lock;
// template< typename T >
// using allocator = typename std::conditional< ENABLE_STD_ALLOCATOR,
// std::allocator< T >,
// bip::allocator<T, bip::managed_mapped_file::segment_manager>
// >::type;

using shared_string = std::conditional< ENABLE_STD_ALLOCATOR,
#ifdef ENABLE_STD_ALLOCATOR
#define _ENABLE_STD_ALLOCATOR 1
#else
#define _ENABLE_STD_ALLOCATOR 0
#endif

using shared_string = std::conditional< _ENABLE_STD_ALLOCATOR,
std::string,
bip::basic_string< char, std::char_traits< char >, allocator< char > >
>::type;

template<typename T>
using t_vector = typename std::conditional< ENABLE_STD_ALLOCATOR,
using t_vector = typename std::conditional< _ENABLE_STD_ALLOCATOR,
std::vector<T, allocator<T> >,
bip::vector<T, allocator<T> >
>::type;
Expand All @@ -58,25 +59,25 @@ namespace chainbase {
using t_allocator_pair = allocator< t_pair< const FIRST_TYPE, SECOND_TYPE > >;

template< typename KEY_TYPE, typename VALUE_TYPE, typename LESS_FUNC = std::less<KEY_TYPE>>
using t_flat_map = typename std::conditional< ENABLE_STD_ALLOCATOR,
using t_flat_map = typename std::conditional< _ENABLE_STD_ALLOCATOR,
boost::container::flat_map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, allocator< t_pair< KEY_TYPE, VALUE_TYPE > > >,
bip::flat_map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, allocator< t_pair< KEY_TYPE, VALUE_TYPE > > >
>::type;

template< typename KEY_TYPE, typename VALUE_TYPE, typename LESS_FUNC = std::less<KEY_TYPE>>
using t_map = typename std::conditional< ENABLE_STD_ALLOCATOR,
using t_map = typename std::conditional< _ENABLE_STD_ALLOCATOR,
std::map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, t_allocator_pair< KEY_TYPE, VALUE_TYPE > >,
bip::map< KEY_TYPE, VALUE_TYPE, LESS_FUNC, t_allocator_pair< KEY_TYPE, VALUE_TYPE > >
>::type;

template< typename T >
using t_deque = typename std::conditional< ENABLE_STD_ALLOCATOR,
using t_deque = typename std::conditional< _ENABLE_STD_ALLOCATOR,
std::deque< T, allocator< T > >,
bip::deque< T, allocator< T > >
>::type;

template< typename T, typename LESS_FUNC >
using t_set = typename std::conditional< ENABLE_STD_ALLOCATOR,
using t_set = typename std::conditional< _ENABLE_STD_ALLOCATOR,
std::set< T, LESS_FUNC, allocator< T > >,
bip::set< T, LESS_FUNC, allocator< T > >
>::type;
Expand Down
4 changes: 2 additions & 2 deletions programs/util/test_shared_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ int main(int argc, char** argv, char** envp)
pbc->emplace( [&]( book& b ) {
b.name = "emplace name";
b.pages = pbc->size();
}, book::allocator_type( seg.get_segment_manager() ) );
}, allocator<book>( seg.get_segment_manager() ) );
#else
pbc->emplace( [&]( book& b ) {
b.name = "emplace name";
b.pages = pbc->size();
}, allocator<book>() );
#endif

#if ENABLE_STD_ALLOCATOR == 0
#ifndef ENABLE_STD_ALLOCATOR
t_deque< book > * deq = seg.find_or_construct<chainbase::t_deque<book>>("book deque")(allocator<book>(seg.get_segment_manager()));
#else
t_deque< book > * deq = new chainbase::t_deque<book>( allocator<book>() );
Expand Down

0 comments on commit ec45dd5

Please sign in to comment.