Skip to content

Commit 0087c29

Browse files
committed
Remove interlocked from fast path.
1 parent cdf6716 commit 0087c29

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/snmalloc/ds_core/stats.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ namespace snmalloc
7777
public:
7878
void operator++(int)
7979
{
80-
value.fetch_add(1, stl::memory_order_relaxed);
80+
auto old = value.load(stl::memory_order_relaxed);
81+
value.store(old + 1, stl::memory_order_relaxed);
8182
}
8283

8384
void operator+=(const MonotoneLocalStat& other)
@@ -88,7 +89,8 @@ namespace snmalloc
8889

8990
void operator+=(size_t v)
9091
{
91-
value.fetch_add(v, stl::memory_order_relaxed);
92+
auto old = value.load(stl::memory_order_relaxed);
93+
value.store(old + v, stl::memory_order_relaxed);
9294
}
9395

9496
size_t operator*()

0 commit comments

Comments
 (0)