mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-20 07:26:47 +00:00
expand artifacts a bit more, to be more useful with larger-than-ptr but not huge allocations
This commit is contained in:
@@ -20,7 +20,7 @@ ac_init(void)
|
||||
////////////////////////////////
|
||||
//~ rjf: Cache Lookups
|
||||
|
||||
internal void *
|
||||
internal AC_Artifact
|
||||
ac_artifact_from_key(Access *access, String8 key, U64 gen, AC_CreateFunctionType *create, AC_DestroyFunctionType *destroy, U64 slots_count)
|
||||
{
|
||||
//- rjf: create function -> cache
|
||||
@@ -60,7 +60,7 @@ ac_artifact_from_key(Access *access, String8 key, U64 gen, AC_CreateFunctionType
|
||||
}
|
||||
|
||||
//- rjf: cache * key -> artifact
|
||||
void *artifact = 0;
|
||||
AC_Artifact artifact = {0};
|
||||
{
|
||||
U64 hash = u64_hash_from_str8(key);
|
||||
U64 slot_idx = hash%cache->slots_count;
|
||||
@@ -222,7 +222,7 @@ ac_async_tick(void)
|
||||
|
||||
// rjf: compute val
|
||||
B32 retry = 0;
|
||||
void *val = reqs[idx].create(reqs[idx].key, &retry);
|
||||
AC_Artifact val = reqs[idx].create(reqs[idx].key, &retry);
|
||||
|
||||
// rjf: retry? -> resubmit request
|
||||
if(retry && lane_idx() == 0)
|
||||
|
||||
@@ -4,11 +4,20 @@
|
||||
#ifndef ARTIFACT_CACHE_H
|
||||
#define ARTIFACT_CACHE_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Artifact Handle Type
|
||||
|
||||
typedef struct AC_Artifact AC_Artifact;
|
||||
struct AC_Artifact
|
||||
{
|
||||
U64 u64[4];
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Artifact Computation Function Types
|
||||
|
||||
typedef void *AC_CreateFunctionType(String8 key, B32 *retry_out);
|
||||
typedef void AC_DestroyFunctionType(void *artifact);
|
||||
typedef AC_Artifact AC_CreateFunctionType(String8 key, B32 *retry_out);
|
||||
typedef void AC_DestroyFunctionType(AC_Artifact artifact);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Cache Types
|
||||
@@ -37,7 +46,7 @@ struct AC_Node
|
||||
// rjf: key/gen/value
|
||||
String8 key;
|
||||
U64 gen;
|
||||
void *val;
|
||||
AC_Artifact val;
|
||||
|
||||
// rjf: metadata
|
||||
AccessPt access_pt;
|
||||
@@ -96,7 +105,7 @@ internal void ac_init(void);
|
||||
////////////////////////////////
|
||||
//~ rjf: Cache Lookups
|
||||
|
||||
internal void *ac_artifact_from_key(Access *access, String8 key, U64 gen, AC_CreateFunctionType *create, AC_DestroyFunctionType *destroy, U64 slots_count);
|
||||
internal AC_Artifact ac_artifact_from_key(Access *access, String8 key, U64 gen, AC_CreateFunctionType *create, AC_DestroyFunctionType *destroy, U64 slots_count);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Asynchronous Tick
|
||||
|
||||
Reference in New Issue
Block a user