/* * KPL specific objects */ #pragma once // for atomic linked list queue // size in bytes, index on the kpl_threads array #define KPL_OBJECT_HEADER(STRUCT_NAME) \ struct STRUCT_NAME *_Atomic queue_next; \ int32_t obj_size, thread_id typedef struct _kpl_object { KPL_OBJECT_HEADER(_kpl_object); } kpl_object; // all kpl objects allocated by the kpl allocator extend this header typedef struct { kpl_object *_Atomic head, *tail; // head is modified with atomic exchange struct { kpl_object *_Atomic queue_next; } dummy; // head and tail are never null will always point to this } kpl_object_queue; // atomic linked list queue any thread can add, only owner thread can remove typedef struct _kpl_task kpl_task; typedef struct _kpl_env kpl_env; typedef void kpl_task_fn(kpl_task *task, kpl_env *env); typedef struct _kpl_task { KPL_OBJECT_HEADER(_kpl_task); // TODO } kpl_task;