diff options
author | Josh Blum | 2012-10-02 21:03:06 -0700 |
---|---|---|
committer | Josh Blum | 2012-10-02 21:03:06 -0700 |
commit | ad4dffb4ea31062de87348e50b77862c5ccdf4c8 (patch) | |
tree | ea13ffb97be6a78a83f828ec3c86c18cfdb6f76a /lib/theron_allocator.cpp | |
parent | ac18fcf142dadaa967cf9ad116048e00c65c2d02 (diff) | |
download | sandhi-ad4dffb4ea31062de87348e50b77862c5ccdf4c8.tar.gz sandhi-ad4dffb4ea31062de87348e50b77862c5ccdf4c8.tar.bz2 sandhi-ad4dffb4ea31062de87348e50b77862c5ccdf4c8.zip |
some minor tweaks to the allocator
Diffstat (limited to 'lib/theron_allocator.cpp')
-rw-r--r-- | lib/theron_allocator.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/theron_allocator.cpp b/lib/theron_allocator.cpp index b8f875f..4f35bbb 100644 --- a/lib/theron_allocator.cpp +++ b/lib/theron_allocator.cpp @@ -28,7 +28,7 @@ #include <Theron/AllocatorManager.h> #include <boost/circular_buffer.hpp> -#define MY_ALLOCATOR_CHUNK_SIZE 88 //Theron asks for a lot of 88-byte buffers +#define MY_ALLOCATOR_CHUNK_SIZE 96 //Theron asks for a lot of 88-byte buffers #define MY_ALLOCATOR_POOL_SIZE (MY_ALLOCATOR_CHUNK_SIZE * 4096) static struct WorkerAllocator : Theron::IAllocator @@ -42,6 +42,7 @@ static struct WorkerAllocator : Theron::IAllocator const ptrdiff_t pool_ptr = ptrdiff_t(pool) + i*MY_ALLOCATOR_CHUNK_SIZE; queue.push_back((void *)pool_ptr); } + pool_end = ptrdiff_t(pool) + MY_ALLOCATOR_POOL_SIZE; Theron::AllocatorManager::Instance().SetAllocator(this); } @@ -70,7 +71,7 @@ static struct WorkerAllocator : Theron::IAllocator void Free(void *const memory) { - const bool in_pool = ptrdiff_t(memory) >= ptrdiff_t(pool) and ptrdiff_t(memory) < (ptrdiff_t(pool) + MY_ALLOCATOR_POOL_SIZE); + const bool in_pool = ptrdiff_t(memory) >= ptrdiff_t(pool) and ptrdiff_t(memory) < pool_end; if (in_pool) { mSpinLock.Lock(); @@ -85,6 +86,7 @@ static struct WorkerAllocator : Theron::IAllocator boost::circular_buffer<void *> queue; long pool[MY_ALLOCATOR_POOL_SIZE/sizeof(long)]; + ptrdiff_t pool_end; Theron::Detail::SpinLock mSpinLock; } my_alloc; |