pull out table stripe arrays as base layer primitive; unified 'artifact cache' experiment

This commit is contained in:
Ryan Fleury
2025-09-22 14:07:21 -07:00
parent 6b278e1ccc
commit 9459327687
8 changed files with 467 additions and 25 deletions
+26
View File
@@ -47,6 +47,25 @@ struct Barrier
U64 u64[1];
};
////////////////////////////////
//~ rjf: Table Stripes
typedef struct Stripe Stripe;
struct Stripe
{
Arena *arena;
RWMutex rw_mutex;
CondVar cv;
void *free;
};
typedef struct StripeArray StripeArray;
struct StripeArray
{
Stripe *v;
U64 count;
};
////////////////////////////////
//~ rjf: Thread Functions
@@ -104,4 +123,11 @@ internal void barrier_wait(Barrier barrier);
#define MutexScopeW(mutex) DeferLoop(rw_mutex_take_w(mutex), rw_mutex_drop_w(mutex))
#define MutexScopeRWPromote(mutex) DeferLoop((rw_mutex_drop_r(mutex), rw_mutex_take_w(mutex)), (rw_mutex_drop_w(mutex), rw_mutex_take_r(mutex)))
////////////////////////////////
//~ rjf: Table Stripe Functions
internal StripeArray stripe_array_alloc(Arena *arena);
internal void stripe_array_release(StripeArray *stripes);
internal Stripe *stripe_from_slot_idx(StripeArray *stripes, U64 slot_idx);
#endif // BASE_THREADS_H