Conversation
…memory management * Move ExportedAlloc inside PoolAllocator (is private now) * Use pointer for current_block_slot * remove num_items, item_size fields * introduce block_pointer (private) to distinguish blocks from slots * Optimize export_all, reusing export_free() * Remove unneeded move_iterators * Simplify allocate() cases
No CamelCase, no _ prefix
…ether current block_slot is null
most important; .tpp is c++ code, so that pool_allocator.tpp gets highlighted properly.
this fixes problem with DartConfiguration.tcl
This should make .h easier to read/understand
f59f61e to
6bbd404
Compare
* Fix compilation error on MSVC due to desginated initializer issue * Fix type mismatch in tests
| size_t bump_remaining() const noexcept; | ||
| // Export: move remaining bump slots to free list and move blocks out. | ||
| // New overload that returns the exported value. | ||
| [[nodiscard]] std::pair<FreeSlotsContainer, BlocksContainer> export_all(); |
There was a problem hiding this comment.
[nitpick] Do you think a struct will be better for scalability? Or std::pair would suffice?
There was a problem hiding this comment.
Good that you're seeing this weakness. Struct is usually much better to explain what's going on, but the specific types here do a reasonably good job of clarifying that, so pair probably suffices. There was a version of this that didn't return values, but instead exported by appending to a pair of vector references passed in. I like the runtime efficiency of the references being modified, but the safety of returning new vectors. It's not worth my time to fix, but if you'd like, feel free to clean this up.
| std::stack<pointer, std::vector<pointer>> free_slots; | ||
| // CRTP mixin that provides object helpers (construct/destroy, new/delete, make_unique) | ||
| // to any Derived that implements allocate(n) and deallocate(ptr, n). | ||
| template <typename Derived, typename T> |
There was a problem hiding this comment.
First time I see CRTP in action. I should read about it more.
There was a problem hiding this comment.
If you want to present CRTP and references, that would be plenty for friday.
No description provided.