#pragma once #include "Allocator.h" #include "Base.h" // #include "Arena.h" struct Arena; // #TEMP - Base_Thread_Context and Arena rely on each other, so I have to figure out how to make this less messy (maybe with meta-generated forward declares?) // See Context_Base in jai, and TCTX in raddebugger: struct Thread_Context { Arena* temp; // Used for temporary allocations. Arena* arena; // general purpose local arena Allocator allocator; u16 GPAllocator_alignment = 16; // Logger logger; // Stack_Trace* stack_trace; // #TODO: other debug information s64 thread_idx; string thread_name; }; Thread_Context* get_thread_context(); #define push_allocator(x) Push_Allocator guard(x) // maybe should append line number to guard? struct Push_Allocator { Thread_Context* context; Allocator old_allocator; Push_Allocator (Allocator new_allocator) { context = get_thread_context(); old_allocator = context->allocator; context->allocator = new_allocator; } ~Push_Allocator () { context->allocator = old_allocator; } };