Skip to content

Commit 0f38f82

Browse files
committed
Add ConcurrencySafe property
Ranges can be safe to call from multiple threads. This adds a constexpr field to signify if that is the case.
1 parent 1a6f5b8 commit 0f38f82

9 files changed

+18
-0
lines changed

src/backend/commitrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ namespace snmalloc
2525

2626
static constexpr bool Aligned = ParentRange::Aligned;
2727

28+
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
29+
2830
constexpr CommitRange() = default;
2931

3032
capptr::Chunk<void> alloc_range(size_t size)

src/backend/empty_range.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace snmalloc
1919

2020
static constexpr bool Aligned = true;
2121

22+
static constexpr bool ConcurrencySafe = true;
23+
2224
constexpr EmptyRange() = default;
2325

2426
capptr::Chunk<void> alloc_range(size_t)

src/backend/globalrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ namespace snmalloc
3737

3838
static constexpr bool Aligned = ParentRange::Aligned;
3939

40+
static constexpr bool ConcurrencySafe = true;
41+
4042
constexpr GlobalRange() = default;
4143

4244
capptr::Chunk<void> alloc_range(size_t size)

src/backend/largebuddyrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ namespace snmalloc
271271

272272
static constexpr bool Aligned = true;
273273

274+
static constexpr bool ConcurrencySafe = false;
275+
274276
constexpr LargeBuddyRange() = default;
275277

276278
capptr::Chunk<void> alloc_range(size_t size)

src/backend/pagemapregisterrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ namespace snmalloc
3030

3131
static constexpr bool Aligned = ParentRange::Aligned;
3232

33+
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
34+
3335
capptr::Chunk<void> alloc_range(size_t size)
3436
{
3537
auto base = state->alloc_range(size);

src/backend/palrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace snmalloc
2424

2525
static constexpr bool Aligned = pal_supports<AlignedAllocation, PAL>;
2626

27+
static constexpr bool ConcurrencySafe = true;
28+
2729
constexpr PalRange() = default;
2830

2931
capptr::Chunk<void> alloc_range(size_t size)

src/backend/smallbuddyrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ namespace snmalloc
175175
static constexpr bool Aligned = true;
176176
static_assert(ParentRange::Aligned, "ParentRange must be aligned");
177177

178+
static constexpr bool ConcurrencySafe = false;
179+
178180
constexpr SmallBuddyRange() = default;
179181

180182
capptr::Chunk<void> alloc_range(size_t size)

src/backend/statsrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace snmalloc
3131

3232
static constexpr bool Aligned = ParentRange::Aligned;
3333

34+
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
35+
3436
constexpr StatsRange() = default;
3537

3638
capptr::Chunk<void> alloc_range(size_t size)

src/backend/subrange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace snmalloc
3131

3232
static constexpr bool Aligned = ParentRange::Aligned;
3333

34+
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
35+
3436
capptr::Chunk<void> alloc_range(size_t sub_size)
3537
{
3638
SNMALLOC_ASSERT(bits::is_pow2(sub_size));

0 commit comments

Comments
 (0)