Add ConcurrencySafe property
Ranges can be safe to call from multiple threads. This adds a constexpr field to signify if that is the case.
This commit is contained in:
committed by
Matthew Parkinson
parent
bdb3183989
commit
e77b9e2851
@@ -235,6 +235,9 @@ namespace snmalloc
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
static_assert(
|
||||||
|
GlobalMetaRange::ConcurrencySafe,
|
||||||
|
"Global meta data range needs to be concurrency safe.");
|
||||||
typename GlobalMetaRange::State global_state;
|
typename GlobalMetaRange::State global_state;
|
||||||
p = global_state->alloc_range(bits::next_pow2(size));
|
p = global_state->alloc_range(bits::next_pow2(size));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = ParentRange::Aligned;
|
static constexpr bool Aligned = ParentRange::Aligned;
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
|
||||||
|
|
||||||
constexpr CommitRange() = default;
|
constexpr CommitRange() = default;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t size)
|
capptr::Chunk<void> alloc_range(size_t size)
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = true;
|
static constexpr bool Aligned = true;
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = true;
|
||||||
|
|
||||||
constexpr EmptyRange() = default;
|
constexpr EmptyRange() = default;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t)
|
capptr::Chunk<void> alloc_range(size_t)
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = ParentRange::Aligned;
|
static constexpr bool Aligned = ParentRange::Aligned;
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = true;
|
||||||
|
|
||||||
constexpr GlobalRange() = default;
|
constexpr GlobalRange() = default;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t size)
|
capptr::Chunk<void> alloc_range(size_t size)
|
||||||
|
|||||||
@@ -271,6 +271,8 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = true;
|
static constexpr bool Aligned = true;
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = false;
|
||||||
|
|
||||||
constexpr LargeBuddyRange() = default;
|
constexpr LargeBuddyRange() = default;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t size)
|
capptr::Chunk<void> alloc_range(size_t size)
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = ParentRange::Aligned;
|
static constexpr bool Aligned = ParentRange::Aligned;
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t size)
|
capptr::Chunk<void> alloc_range(size_t size)
|
||||||
{
|
{
|
||||||
auto base = state->alloc_range(size);
|
auto base = state->alloc_range(size);
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = pal_supports<AlignedAllocation, PAL>;
|
static constexpr bool Aligned = pal_supports<AlignedAllocation, PAL>;
|
||||||
|
|
||||||
|
// Note we have always assumed the Pals to provide a concurrency safe
|
||||||
|
// API. If in the future this changes, then this would
|
||||||
|
// need to be changed.
|
||||||
|
static constexpr bool ConcurrencySafe = true;
|
||||||
|
|
||||||
constexpr PalRange() = default;
|
constexpr PalRange() = default;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t size)
|
capptr::Chunk<void> alloc_range(size_t size)
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ namespace snmalloc
|
|||||||
static constexpr bool Aligned = true;
|
static constexpr bool Aligned = true;
|
||||||
static_assert(ParentRange::Aligned, "ParentRange must be aligned");
|
static_assert(ParentRange::Aligned, "ParentRange must be aligned");
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = false;
|
||||||
|
|
||||||
constexpr SmallBuddyRange() = default;
|
constexpr SmallBuddyRange() = default;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t size)
|
capptr::Chunk<void> alloc_range(size_t size)
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = ParentRange::Aligned;
|
static constexpr bool Aligned = ParentRange::Aligned;
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
|
||||||
|
|
||||||
constexpr StatsRange() = default;
|
constexpr StatsRange() = default;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t size)
|
capptr::Chunk<void> alloc_range(size_t size)
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ namespace snmalloc
|
|||||||
|
|
||||||
static constexpr bool Aligned = ParentRange::Aligned;
|
static constexpr bool Aligned = ParentRange::Aligned;
|
||||||
|
|
||||||
|
static constexpr bool ConcurrencySafe = ParentRange::ConcurrencySafe;
|
||||||
|
|
||||||
capptr::Chunk<void> alloc_range(size_t sub_size)
|
capptr::Chunk<void> alloc_range(size_t sub_size)
|
||||||
{
|
{
|
||||||
SNMALLOC_ASSERT(bits::is_pow2(sub_size));
|
SNMALLOC_ASSERT(bits::is_pow2(sub_size));
|
||||||
|
|||||||
Reference in New Issue
Block a user