diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-11-11 14:05:59 -0500 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-11-11 14:05:59 -0500 |
| commit | 75c8828d804f45cf8f44af73bfe87e0f3eaf9a9e (patch) | |
| tree | 2fdf51906d2517bbe8c928fc52f95bb2e0dda4f9 /include/kpl/env.h | |
| parent | 7b9204a8680539bc4795a14f3d9a34e47981d0c3 (diff) | |
run a task test
Diffstat (limited to 'include/kpl/env.h')
| -rw-r--r-- | include/kpl/env.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/include/kpl/env.h b/include/kpl/env.h index 11f90b3..c4237fa 100644 --- a/include/kpl/env.h +++ b/include/kpl/env.h @@ -34,7 +34,8 @@ typedef enum : uint32_t { KPL_ENV_FLAG_HAS_ERROR = 1 << 1, KPL_ENV_FLAG_RUN_MODULE = 1 << 2, KPL_ENV_FLAG_RUN_EVAL = 1 << 3, - KPL_ENV_FLAG_RUN_REPL = 1 << 4 + KPL_ENV_FLAG_RUN_REPL = 1 << 4, + KPL_ENV_FLAG_RUN_FUNCTION = 1 << 5 } kpl_env_flags; /* @@ -50,7 +51,10 @@ typedef struct _kpl_env { _Atomic uint32_t flags; // see kpl_env_flags for values, any thread can modify or check needs atomic int32_t io_uring_queue_size_pow2; // the power of two to calculate the entries in the io_uring queue int32_t thread_count; // -1 updates this value to max possible, 0 invalid, >= 1 for specific number - const char *kpl_entry; // file or string to be ran, not used for repl, pointer used to get kpl args namespace + union { + const char *kpl_c_string_entry; // file or string, not used for repl, pointer used in kpl args namespace + kpl_task_fn *kpl_fn_entry; // a task function, for a task with no variables, placed on main thread + }; // only one entry point can be defined _Atomic ssize_t total_priority; // the sum of the threads priority fields, application stops on zero kpl_thread *threads; // 0 is main thread, >= 1 are spawned pthreads kpl_tree namespace_tree, module_tree; // Trees of kpl_storage @@ -71,11 +75,6 @@ kpl_exit_code kpl_env_config(kpl_env *env, int32_t argc, char *argv[]); */ kpl_exit_code kpl_env_init(kpl_env *env); -typedef enum : uint8_t { - KPL_ENV_QUEUE_MODE_ASYNC = 0, - KPL_ENV_QUEUE_MODE_SYNC = 1 -} kpl_env_queue_mode; - /* * Increase priority by one */ @@ -100,13 +99,17 @@ inline void kpl_env_priority_decrement(kpl_thread *thread) { thread->env->total_priority--; } +typedef enum : uint8_t { + KPL_ENV_QUEUE_MODE_ASYNC = 0, + KPL_ENV_QUEUE_MODE_SYNC = 1 +} kpl_env_queue_mode; + /* * queue_mode ASYNC queues thread with lowest priority * queue_mode SYNC queues thread on threads[task->thread_id] */ void kpl_env_queue_task(kpl_env *env, kpl_object_task *task, kpl_env_queue_mode queue_mode); - /* * Run once, not re-enetrant * TODO RUN TASK AND IO ORDERING |
