aboutsummaryrefslogtreecommitdiff
path: root/src/common_memory.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-07-15 01:36:54 +0100
committergingerBill <bill@gingerbill.org>2024-07-15 01:36:54 +0100
commita45e05bb180ad5ac3f9bc4199ebbf0b3bcadbf25 (patch)
tree0b597a5c0d3e6a5fe1f984ab58b645f23deef342 /src/common_memory.cpp
parente4ba786948e8f3abe89ff2ec6b7618f4af2b21cb (diff)
Remove need for `BlockingMutex` in `Arena`
Diffstat (limited to 'src/common_memory.cpp')
-rw-r--r--src/common_memory.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/common_memory.cpp b/src/common_memory.cpp
index bfe4c2e68..47b2796a9 100644
--- a/src/common_memory.cpp
+++ b/src/common_memory.cpp
@@ -45,7 +45,7 @@ struct MemoryBlock {
struct Arena {
MemoryBlock * curr_block;
isize minimum_block_size;
- BlockingMutex mutex;
+ // BlockingMutex mutex;
isize temp_count;
Thread * parent_thread;
};
@@ -82,12 +82,7 @@ gb_internal void thread_init_arenas(Thread *t) {
gb_internal void *arena_alloc(Arena *arena, isize min_size, isize alignment) {
GB_ASSERT(gb_is_power_of_two(alignment));
-
- if (arena->parent_thread == nullptr) {
- mutex_lock(&arena->mutex);
- } else {
- GB_ASSERT(arena->parent_thread == get_current_thread());
- }
+ GB_ASSERT(arena->parent_thread == get_current_thread());
isize size = 0;
if (arena->curr_block != nullptr) {
@@ -113,11 +108,7 @@ gb_internal void *arena_alloc(Arena *arena, isize min_size, isize alignment) {
curr_block->used += size;
GB_ASSERT(curr_block->used <= curr_block->size);
-
- if (arena->parent_thread == nullptr) {
- mutex_unlock(&arena->mutex);
- }
-
+
// NOTE(bill): memory will be zeroed by default due to virtual memory
return ptr;
}