Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions include/hexi/allocators/tls_block_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class tls_block_allocator final {
* When used in conjunction with unsafe_entrant, allows the owning object
* to be executed on another thread without paying for checks on every
* allocation
*
* @note If ref counting is enabled, the count will be incremented.
*/
inline void thread_enter() {
if(!allocator_) {
Expand All @@ -93,6 +95,12 @@ class tls_block_allocator final {
}
}

/*
* When used in conjunction with unsafe_entrant, signals that the current
* thread not make further calls into the allocator.
*
* @note If ref counting is enabled, the count will be decremented.
*/
inline void thread_exit() {
if constexpr(std::is_same_v<ref_count_policy, ref_counting>) {
assert(ref_count_);
Expand All @@ -105,6 +113,13 @@ class tls_block_allocator final {
}
}

/*
* @brief Allocates and constructs an object.
*
* @tparam Args Variadic arguments to be forwarded to the object's constructor.
*
* @return Pointer to the allocated object.
*/
template<typename ...Args>
[[nodiscard]] inline _ty* allocate(Args&&... args) {
/*
Expand All @@ -121,6 +136,11 @@ class tls_block_allocator final {
return allocator_handle()->allocate(std::forward<Args>(args)...);
}

/*
* @brief Deallocates and destructs an object.
*
* @param t The object to be deallocated.
*/
inline void deallocate(_ty* t) {
assert(t);

Expand Down
Loading