Improved ThreadAlloc::get API
Made the API so that get always returns an initialised Alloc*. Added new fast path that doesn't perform checking, but can lead to very slow behaviour if called and reused.
This commit is contained in:
@@ -75,7 +75,7 @@ size_t swapcount;
|
||||
|
||||
void test_tasks_f(size_t id)
|
||||
{
|
||||
Alloc*& a = ThreadAlloc::get();
|
||||
Alloc* a = ThreadAlloc::get();
|
||||
xoroshiro::p128r32 r(id + 5000);
|
||||
|
||||
for (size_t n = 0; n < swapcount; n++)
|
||||
@@ -100,7 +100,7 @@ void test_tasks_f(size_t id)
|
||||
|
||||
void test_tasks(size_t num_tasks, size_t count, size_t size)
|
||||
{
|
||||
Alloc*& a = ThreadAlloc::get();
|
||||
Alloc* a = ThreadAlloc::get();
|
||||
|
||||
contention = new std::atomic<size_t*>[size];
|
||||
xoroshiro::p128r32 r;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace test
|
||||
|
||||
void test_external_pointer(xoroshiro::p128r64& r)
|
||||
{
|
||||
auto& alloc = ThreadAlloc::get();
|
||||
auto alloc = ThreadAlloc::get();
|
||||
#ifdef NDEBUG
|
||||
static constexpr size_t iterations = 10000000;
|
||||
#else
|
||||
@@ -79,9 +79,6 @@ namespace test
|
||||
int main(int, char**)
|
||||
{
|
||||
xoroshiro::p128r64 r;
|
||||
// Force a per-thread allocator to actually exist.
|
||||
void* p = ThreadAlloc::get()->alloc(16);
|
||||
ThreadAlloc::get()->dealloc(p);
|
||||
#if NDEBUG
|
||||
size_t nn = 30;
|
||||
#else
|
||||
|
||||
@@ -7,7 +7,7 @@ using namespace snmalloc;
|
||||
template<ZeroMem zero_mem>
|
||||
void test_alloc_dealloc(size_t count, size_t size, bool write)
|
||||
{
|
||||
auto*& alloc = ThreadAlloc::get();
|
||||
auto* alloc = ThreadAlloc::get();
|
||||
|
||||
DO_TIME(
|
||||
"Count: " << std::setw(6) << count << ", Size: " << std::setw(6) << size
|
||||
|
||||
Reference in New Issue
Block a user