finished reviewing thread_context.h/c for now

This commit is contained in:
2025-02-05 23:56:04 -05:00
parent af0dc24160
commit 259cb23810
2 changed files with 18 additions and 4 deletions
+15 -1
View File
@@ -1,4 +1,5 @@
#ifdef INTELLISENSE_DIRECTIVES
# include "arena.h"
# include "thread_context.h"
#endif
@@ -19,7 +20,20 @@ tctx_init_and_equip(TCTX* tctx){
memory_zero_struct(tctx);
Arena** arena_ptr = tctx->arenas;
for (U64 i = 0; i < array_count(tctx->arenas); i += 1, arena_ptr += 1) {
*arena_ptr = arena_alloc();
// TODO(Ed): Review this, we are not exposing a way for the user to defining the backing of these thread-context arenas.
VArena* vm = varena_alloc(.reserve_size = VARENA_DEFAULT_RESERVE, .commit_size = VARENA_DEFAULT_COMMIT);
*arena_ptr = arena_alloc(.backing = varena_allocator(vm));
}
tctx_thread_local = tctx;
}
void
tctx_init_and_equip_ainfos(TCTX* tctx, AllocatorInfo ainfos[2]) {
memory_zero_struct(tctx);
Arena** arena_ptr = tctx->arenas;
for (U64 i = 0; i < array_count(tctx->arenas); i += 1, arena_ptr += 1) {
// TODO(Ed): Is this ok? Is it alright that the thread context can use Arenas?
*arena_ptr = arena_alloc(.backing = ainfos[i]);
}
tctx_thread_local = tctx;
}