mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-07 16:18:49 +00:00
finished reviewing thread_context.h/c for now
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#ifdef INTELLISENSE_DIRECTIVES
|
#ifdef INTELLISENSE_DIRECTIVES
|
||||||
|
# include "arena.h"
|
||||||
# include "thread_context.h"
|
# include "thread_context.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -19,7 +20,20 @@ tctx_init_and_equip(TCTX* tctx){
|
|||||||
memory_zero_struct(tctx);
|
memory_zero_struct(tctx);
|
||||||
Arena** arena_ptr = tctx->arenas;
|
Arena** arena_ptr = tctx->arenas;
|
||||||
for (U64 i = 0; i < array_count(tctx->arenas); i += 1, arena_ptr += 1) {
|
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;
|
tctx_thread_local = tctx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,7 @@
|
|||||||
typedef struct TCTX TCTX;
|
typedef struct TCTX TCTX;
|
||||||
struct TCTX
|
struct TCTX
|
||||||
{
|
{
|
||||||
AllocatorInfo ainfos[2];
|
Arena* arenas[2];
|
||||||
Arena* arenas[2];
|
|
||||||
|
|
||||||
U8 thread_name[32];
|
U8 thread_name[32];
|
||||||
U64 thread_name_size;
|
U64 thread_name_size;
|
||||||
@@ -26,7 +25,8 @@ struct TCTX
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// NOTE(allen): Thread Context Functions
|
// NOTE(allen): Thread Context Functions
|
||||||
|
|
||||||
MD_API void tctx_init_and_equip(TCTX *tctx, AllocatorInfo ainfo);
|
MD_API void tctx_init_and_equip(TCTX *tctx);
|
||||||
|
MD_API void tctx_init_and_equip_ainfos(TCTX *tctx, AllocatorInfo ainfos[2]);
|
||||||
MD_API void tctx_release(void);
|
MD_API void tctx_release(void);
|
||||||
MD_API TCTX* tctx_get_equipped(void);
|
MD_API TCTX* tctx_get_equipped(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user