diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-06-04 17:22:25 -0400 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-06-04 17:22:25 -0400 |
| commit | 1d5f5dd3cd5cc07352379fe33930770e3d203f3a (patch) | |
| tree | 9a92bdf7a34b99065d8f67f296b86743d34b2b84 /docs/application/thread.md | |
| parent | a8810a00d95678cceee2a063df9c094fa6f6037d (diff) | |
use await and more application definitions
Diffstat (limited to 'docs/application/thread.md')
| -rw-r--r-- | docs/application/thread.md | 15 |
1 files changed, 9 insertions, 6 deletions
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" ) */ |
