From 8ed799bd4dd9f1c534a0ae629c15e41f84663391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Dee=20=28J=C5=8Dshin=29?= Date: Fri, 18 Apr 2025 00:49:00 -0700 Subject: [PATCH] Make refcount reads explicitly atomic --- ctl/shared_ptr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctl/shared_ptr.h b/ctl/shared_ptr.h index 78cf4aeb2..6f04f2e9d 100644 --- a/ctl/shared_ptr.h +++ b/ctl/shared_ptr.h @@ -97,12 +97,12 @@ class shared_ref size_t use_count() const noexcept { - return shared + 1; + return __atomic_load_n(&shared, __ATOMIC_RELAXED) + 1; } size_t weak_count() const noexcept { - return weak; + return __atomic_load_n(&weak, __ATOMIC_RELAXED); } private: