Small algorithm improvements to avoid allocations

TL depends on cppcoro now
This commit is contained in:
jeanlemotan
2024-07-03 16:14:16 +02:00
parent c898a3b653
commit b307f44333
3 changed files with 55 additions and 92 deletions
+2 -2
View File
@@ -113,7 +113,7 @@ extern thread_local int32_t s_ptr_checking_disabled;
#define CB_LENT_DEC_REF() \
if (m_cb) [[likely]] \
{ \
bool is_dangling = m_cb->unique_count.load(tl::memory_order_acquire) == 0; \
const bool is_dangling = m_cb->unique_count.load(tl::memory_order_acquire) == 0; \
if (is_dangling && is_ptr_checking_enabled()) [[unlikely]] \
TL_FAIL("lent: {} dangling lent ptrs detected", m_cb->lent_count.load(tl::memory_order_acquire)); \
if (m_cb->lent_count.fetch_sub(1, tl::memory_order_acquire) == 1) /* last one? cleanup */ \
@@ -144,7 +144,7 @@ extern thread_local int32_t s_ptr_checking_disabled;
#define CB_UNIQUE_DEC_REF() \
if (m_cb && m_cb->unique_count.fetch_sub(1, tl::memory_order_acquire) == 1) [[likely]] \
{ \
int32_t count = m_cb->lent_count.load(tl::memory_order_acquire); \
const int32_t count = m_cb->lent_count.load(tl::memory_order_acquire); \
if (count == 0) [[likely]] \
delete m_cb; \
else if (is_ptr_checking_enabled()) [[likely]] \