14 #ifndef FOXXLL_MNG_BLOCK_ALLOC_STRATEGY_HEADER 15 #define FOXXLL_MNG_BLOCK_ALLOC_STRATEGY_HEADER 38 static const char *
name();
49 : begin_(begin), diff_(end - begin) { }
58 return begin_ + i % diff_;
72 mutable std::default_random_engine rng_ { std::random_device { } () };
81 return begin_ + rng_() % diff_;
86 return "fully randomized striping";
99 std::default_random_engine rng { std::random_device { } () };
100 offset = rng() % diff_;
116 return begin_ + (i + offset) % diff_;
121 return "simple randomized striping";
134 for (
size_t i = 0; i < diff_; i++)
137 std::random_shuffle(perm_.begin(), perm_.end());
142 :
striping(begin, end), perm_(diff_)
154 return begin_ + perm_[i % diff_];
159 return "randomized cycling striping";
169 config::get_instance()->regular_disk_range().second)
174 return "Randomized cycling striping on regular disks";
185 config::get_instance()->flash_range().second)
190 return "Randomized cycling striping on flash devices";
200 explicit single_disk(
size_t disk = 0,
size_t = 0) : disk_(disk) { }
209 return "single disk";
216 template <
class BaseAllocator>
227 : base_(base), offset_(offset) { }
232 : base_(base), offset_(0) { }
239 return base_(offset_ + i);
259 #endif // !FOXXLL_MNG_BLOCK_ALLOC_STRATEGY_HEADER
static const char * name()
offset_allocator(int offset, const BaseAllocator &base)
random_cyclic(size_t begin, size_t end)
static const char * name()
offset_allocator()
Creates functor based on default BaseAllocator functor.
fully_random(size_t begin, size_t end)
simple_random(size_t begin, size_t end)
single_disk(size_t disk=0, size_t=0)
random_cyclic_disk(size_t begin, size_t end)
static const char * name()
static const char * name()
static const char * name()
static const char * name()
static instance_pointer get_instance()
return instance or create base instance if empty
basic_allocation_strategy()
offset_allocator(const BaseAllocator &base)
size_t operator()(size_t i) const
static const char * name()
std::vector< size_t > perm_
random_cyclic_flash(size_t begin, size_t end)
static const char * name()
striping(size_t begin, size_t end)