9 #include <density/detail/page_allocator.h> 10 #include <density/detail/system_page_manager.h> 158 template <
size_t PAGE_CAPACITY_AND_ALIGNMENT = default_page_capacity>
162 using PageAllocator =
163 detail::PageAllocator<typename detail::SystemPageManager<PAGE_CAPACITY_AND_ALIGNMENT>>;
167 static constexpr
size_t page_size = PageAllocator::page_size;
188 void *
allocate(
size_t i_size,
size_t i_alignment,
size_t i_alignment_offset = 0)
210 try_allocate(
size_t i_size,
size_t i_alignment,
size_t i_alignment_offset = 0) noexcept
231 void * i_block,
size_t i_size,
size_t i_alignment,
size_t i_alignment_offset = 0) noexcept
245 auto const new_page =
246 PageAllocator::thread_local_instance()
247 .template try_allocate_page<detail::page_allocation_type::uninitialized>(
249 if (new_page ==
nullptr)
250 throw std::bad_alloc();
263 return PageAllocator::thread_local_instance()
264 .template try_allocate_page<detail::page_allocation_type::uninitialized>(
265 i_progress_guarantee);
277 auto const new_page =
278 PageAllocator::thread_local_instance()
279 .template try_allocate_page<detail::page_allocation_type::zeroed>(
281 if (new_page ==
nullptr)
282 throw std::bad_alloc();
295 return PageAllocator::thread_local_instance()
296 .template try_allocate_page<detail::page_allocation_type::zeroed>(
297 i_progress_guarantee);
312 PageAllocator::thread_local_instance()
313 .template deallocate_page<detail::page_allocation_type::uninitialized>(i_page);
329 PageAllocator::thread_local_instance()
330 .template deallocate_page<detail::page_allocation_type::zeroed>(i_page);
352 throw std::bad_alloc();
375 size_t * o_reserved_size =
nullptr) noexcept
377 auto const reserved_size =
378 PageAllocator::thread_local_instance().try_reserve_lockfree_memory(
379 i_progress_guarantee, i_size);
380 if (o_reserved_size !=
nullptr)
381 *o_reserved_size = reserved_size;
382 return reserved_size >= i_size;
407 void pin_page(
void * i_page) noexcept { PageAllocator::pin_page(i_page); }
417 void unpin_page(
void * i_address) noexcept { PageAllocator::unpin_page(i_address); }
427 return PageAllocator::try_pin_page(i_progress_guarantee, i_address);
440 return PageAllocator::unpin_page(i_progress_guarantee, i_address);
452 return PageAllocator::get_pin_count(i_address);
static void reserve_lockfree_page_memory(size_t i_size, size_t *o_reserved_size=nullptr)
Definition: default_allocator.h:348
Definition: conc_function_queue.h:11
void deallocate_page_zeroed(void *i_page) noexcept
Definition: default_allocator.h:327
bool operator==(const basic_default_allocator &) const noexcept
Definition: default_allocator.h:457
Definition: density_common.h:86
bool operator!=(const basic_default_allocator &) const noexcept
Definition: default_allocator.h:461
void * try_allocate_page_zeroed(progress_guarantee i_progress_guarantee) noexcept
Definition: default_allocator.h:293
uintptr_t get_pin_count(const void *i_address) noexcept
Definition: default_allocator.h:450
bool try_pin_page(progress_guarantee i_progress_guarantee, void *i_address) noexcept
Definition: default_allocator.h:425
static bool try_reserve_lockfree_page_memory(progress_guarantee i_progress_guarantee, size_t i_size, size_t *o_reserved_size=nullptr) noexcept
Definition: default_allocator.h:372
void * allocate_page()
Definition: default_allocator.h:243
Definition: default_allocator.h:149
progress_guarantee
Definition: density_common.h:84
void * allocate_page_zeroed()
Definition: default_allocator.h:275
void * try_allocate(size_t i_size, size_t i_alignment, size_t i_alignment_offset=0) noexcept
Definition: default_allocator.h:210
void deallocate(void *i_block, size_t i_size, size_t i_alignment, size_t i_alignment_offset=0) noexcept
Definition: default_allocator.h:230
void * try_allocate_page(progress_guarantee i_progress_guarantee) noexcept
Definition: default_allocator.h:261
void * aligned_allocate(size_t i_size, size_t i_alignment, size_t i_alignment_offset=0)
Definition: density_common.h:460
void unpin_page(void *i_address) noexcept
Definition: default_allocator.h:417
void unpin_page(progress_guarantee i_progress_guarantee, void *i_address) noexcept
Definition: default_allocator.h:438
void pin_page(void *i_page) noexcept
Definition: default_allocator.h:407
void * try_aligned_allocate(size_t i_size, size_t i_alignment, size_t i_alignment_offset=0) noexcept
Definition: density_common.h:510
static constexpr size_t page_size
Definition: default_allocator.h:167
void aligned_deallocate(void *i_block, size_t i_size, size_t i_alignment, size_t i_alignment_offset=0) noexcept
Definition: density_common.h:564
static constexpr size_t page_alignment
Definition: default_allocator.h:170
void * allocate(size_t i_size, size_t i_alignment, size_t i_alignment_offset=0)
Definition: default_allocator.h:188
#define DENSITY_ASSUME(bool_expr,...)
Definition: density_config.h:46
void deallocate_page(void *i_page) noexcept
Definition: default_allocator.h:309