From 1d5f5dd3cd5cc07352379fe33930770e3d203f3a Mon Sep 17 00:00:00 2001 From: nodist Date: Thu, 4 Jun 2026 17:22:25 -0400 Subject: use await and more application definitions --- docs/application/buffer.md | 14 ++++++++++ docs/application/index.md | 30 ++++++++++++---------- docs/application/interface.md | 9 +++++++ docs/application/map.md | 3 +++ docs/application/namespace.md | 60 ++++++++++++++++++++++++++++++++++++++++--- docs/application/pool.md | 4 +++ docs/application/queue.md | 3 +++ docs/application/thread.md | 15 ++++++----- docs/application/tuple.md | 13 ++++++++++ 9 files changed, 127 insertions(+), 24 deletions(-) create mode 100644 docs/application/buffer.md create mode 100644 docs/application/map.md create mode 100644 docs/application/queue.md create mode 100644 docs/application/tuple.md (limited to 'docs/application') diff --git a/docs/application/buffer.md b/docs/application/buffer.md new file mode 100644 index 0000000..d72eb8a --- /dev/null +++ b/docs/application/buffer.md @@ -0,0 +1,14 @@ +# Buffer + +--- + +## Object Definitions + +```c +typedef struct _kpl_buffer { + POOL_HEADER(_kpl_buffer); + uint32_t byte_length; + kpl_interface *interface; + uint8_t bytes; +} kpl_buffer; +``` diff --git a/docs/application/index.md b/docs/application/index.md index e7e719f..7d97cda 100644 --- a/docs/application/index.md +++ b/docs/application/index.md @@ -6,7 +6,7 @@ * Linux X64 * GNU Make -* GCC with -std=gnu99 -fhardened +* GCC with -std=gnu99 -fhardened (14+) # Sections @@ -14,6 +14,10 @@ * ##### [Type](./type.md) * ##### [Pool](./pool.md) * ##### [Thread](./thread.md) +* ##### [Tuple](./tuple.md) +* ##### [Buffer](./buffer.md) +* ##### [Map](./map.md) +* ##### [Queue](./queue.md) * ##### [Namespace](./namespace.md) * ##### [Testing](./testing.md) @@ -21,22 +25,20 @@ ## Startup -```c -void kpl_init(void); -``` - ## Main -```c -void kpl_main(int argc, char *argv[]); -``` +### File -## File +### String/REPL -## REPL +## Evaluation -## Shutdown +1. ##### Scan +2. ##### Parse +3. ##### Scope +4. ##### Check +5. ##### Eval +6. ##### Jit +7. ##### Exec -```c -void kpl_free(void) -``` +## Shutdown diff --git a/docs/application/interface.md b/docs/application/interface.md index 3f270bd..5042bb4 100644 --- a/docs/application/interface.md +++ b/docs/application/interface.md @@ -32,6 +32,15 @@ typedef int32_t kpl_any_print_fn(const kpl_any a, FILE *file, size_t idnt, uint3 typedef void kpl_any_free_fn(kpl_any a); +typedef struct { + // TODO +} kpl_interface; + +typedef struct { + kpl_any *any; + kpl_interface *interflace; +} kpl_class; + typedef struct { any value, info; } kpl_result; diff --git a/docs/application/map.md b/docs/application/map.md new file mode 100644 index 0000000..b9d8fa0 --- /dev/null +++ b/docs/application/map.md @@ -0,0 +1,3 @@ +# Map + +--- diff --git a/docs/application/namespace.md b/docs/application/namespace.md index 47f6105..f49ebf1 100644 --- a/docs/application/namespace.md +++ b/docs/application/namespace.md @@ -4,10 +4,62 @@ ## Object Definitions -# Native Registering +```c +typedef struct _kpl_native_namespace { + POOL_HEADER(_kpl_native_namespace); + kpl_buffer *name; + kpl_map *exports; + pthread_mutex_t mutex; +} kpl_native_namespace; +``` -# File Registering +```c +typedef struct _kpl_file_namespace { + POOL_HEADER(_kpl_file_namespace); + __Atomic int16_t children; + uint16_t flags; + kpl_buffer *file_name, *file_string; + kpl_map *parents, *exports; + // TODO AST + kpl_interface *interface; + kpl_task *task; + pthread_mutex_t mutex; +} kpl_file_namespace; +``` -## Import +```c +typedef struct _kpl_string_namespace { + kpl_buffer *string; + // TODO AST + kpl_interface *interface; + kpl_task *task; +} kpl_string_namespace; +``` -## Export +# Registering + +## Native + +## File + +### Main + +### ``import` + +## String/REPL + +# Updating + +## File + +### ``export` + +# Using + +## Native + +### ``use` + +## File + +### ``import` diff --git a/docs/application/pool.md b/docs/application/pool.md index b4c5913..a73dd82 100644 --- a/docs/application/pool.md +++ b/docs/application/pool.md @@ -11,3 +11,7 @@ typedef struct _kpl_pool_obj { POOL_HEADER(_kpl_pool_obj); } kpl_pool_obj; ``` + +## List Management + +## Tree Management diff --git a/docs/application/queue.md b/docs/application/queue.md new file mode 100644 index 0000000..86c4009 --- /dev/null +++ b/docs/application/queue.md @@ -0,0 +1,3 @@ +# Queue + +--- diff --git a/docs/application/thread.md b/docs/application/thread.md index a11c01f..4ee5688 100644 --- a/docs/application/thread.md +++ b/docs/application/thread.md @@ -17,9 +17,10 @@ typedef struct _kpl_task { POOL_HEADER(kpl_task); _Atomic bool join_ready; uint16_t worker_id; - kpl_any state[KPL_TASK_STATE_SIZE]; - kpl_result ret; kpl_task_fn *fn; + kpl_interface *ret_interface; + kpl_result ret; + kpl_class state[KPL_TASK_STATE_SIZE]; } kpl_task; typedef struct { @@ -27,9 +28,11 @@ typedef struct { pthread_t thread; } kpl_thread; -#define KPL_THREADS $(nproc) +#define KPL_MAX_THREADS 64 + +uint16_t available_threads; // find with sched_getaffinity -_Atomic uint16_t running; // init to KPL_THREADS +_Atomic uint16_t running_threads; // init to available_threads kpl_task *async_queue_head, *async_queue_tail; @@ -37,7 +40,7 @@ pthread_mutex_t async_mutex; pthread_cond_t async_cond; -kpl_thread threads[KPL_THREADS]; +kpl_thread threads[KPL_MAX_THREADS]; ``` ## Per Process Task Queue @@ -244,7 +247,7 @@ fib : Fn[n] $ ( } v : Array[`fork_type fib] $ () @ 1 .. I { v `push fib `async FIB } - @ v {[fib_task] `print "fib(%) = %\n" `format (FIB; `wait fib_task) } + @ v {[fib_task] `print "fib(%) = %\n" `format (FIB; `await fib_task) } `print "Complete\n" ) */ diff --git a/docs/application/tuple.md b/docs/application/tuple.md new file mode 100644 index 0000000..e0e926c --- /dev/null +++ b/docs/application/tuple.md @@ -0,0 +1,13 @@ +# Tuple + +--- + +## Object Definitions + +```c +typedef struct _kpl_tuple { + POOL_HEADER(_kpl_tuple); + uint32_t item_length; + kpl_class items[]; +} kpl_tuple; +``` -- cgit v1.2.3