diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/kpl/env.h | 25 | ||||
| -rw-r--r-- | include/kpl/gc.h | 1 | ||||
| -rw-r--r-- | include/kpl/identifier.h | 13 | ||||
| -rw-r--r-- | include/kpl/io.h | 6 | ||||
| -rw-r--r-- | include/kpl/object.h | 2 |
5 files changed, 44 insertions, 3 deletions
diff --git a/include/kpl/env.h b/include/kpl/env.h index 0cab4bc..11f90b3 100644 --- a/include/kpl/env.h +++ b/include/kpl/env.h @@ -77,11 +77,36 @@ typedef enum : uint8_t { } kpl_env_queue_mode; /* + * Increase priority by one + */ +inline void kpl_env_priority_increment(kpl_thread *thread) { + thread->priority++; + thread->env->total_priority++; +} + +/* + * Increase priority by amount + */ +inline void kpl_env_priority_add(kpl_thread *thread, ssize_t amount) { + thread->priority += amount; + thread->env->total_priority += amount; +} + +/* + * Decrease priority by one + */ +inline void kpl_env_priority_decrement(kpl_thread *thread) { + thread->priority--; + thread->env->total_priority--; +} + +/* * 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 diff --git a/include/kpl/gc.h b/include/kpl/gc.h index 074ba49..6ed4fc4 100644 --- a/include/kpl/gc.h +++ b/include/kpl/gc.h @@ -47,6 +47,7 @@ inline void kpl_gc_mark(kpl_object_gc *object_gc) { /* * Move gc_head to gc_mark head * Need task to traverse task and error queue to mark objects all call kpl_interface_gc_mark_object_fn + * Has to be called separately from kpl_gc_sweep, other tasks will be running while gc runs */ inline void kpl_gc_prepare_sweep(kpl_gc *gc) { gc->gc_mark_head = gc->gc_head; diff --git a/include/kpl/identifier.h b/include/kpl/identifier.h index a30b4a7..9bb42b0 100644 --- a/include/kpl/identifier.h +++ b/include/kpl/identifier.h @@ -43,3 +43,16 @@ void kpl_identifier_decode(kpl_identifier *identifier, char c_string[KPL_IDENTIF * 0 - equal, negative - left < right, positive - left > right */ int32_t kpl_identifier_compare(const kpl_identifier *identifier_left, const kpl_identifier *identifier_right); + +/* + * Check if two identifiers are equal + * Faster then comparing when equality check is needed + */ +inline bool kpl_identifier_equal(const kpl_identifier *identifier_a, const kpl_identifier *identifier_b) { + for (int32_t part_index = 0; part_index < KPL_IDENTIFIER_PARTS; part_index++) + if (!identifier_a->parts[part_index] && !identifier_b->parts[part_index]) + break; + else if (identifier_a->parts[part_index] != identifier_b->parts[part_index]) + return false; + return true; +} diff --git a/include/kpl/io.h b/include/kpl/io.h index 3838a55..30503ad 100644 --- a/include/kpl/io.h +++ b/include/kpl/io.h @@ -48,14 +48,16 @@ inline void kpl_io_uring_free(kpl_io_uring *io_uring) { * This will wait if io uring enter is called * NULL for none completed * If an error occurred, the error details will be on the kpl_task_object + * *thread is needed to decrease priority */ -kpl_object_task *kpl_io_uring_get_completed(kpl_io_uring *io_uring); +kpl_object_task *kpl_io_uring_get_completed(kpl_thread *thread); /* * Submits all sqes (added_to_queue has total) in one io uring eneter * This does not wait + * *thread is need to increase priority by the number of operations submitted */ -int32_t kpl_io_uring_submit(kpl_io_uring *io_uring); +int32_t kpl_io_uring_submit(kpl_thread *thread); /* * Only call this though one of the functions below to add an operation to the queue diff --git a/include/kpl/object.h b/include/kpl/object.h index b157719..e6e2340 100644 --- a/include/kpl/object.h +++ b/include/kpl/object.h @@ -79,7 +79,7 @@ typedef struct _kpl_object_error { int32_t error_line; } kpl_object_error; -typedef kpl_object_error *kpl_task_fn(kpl_object_task *task, kpl_env *env); +typedef kpl_object_error *kpl_task_fn(kpl_object_task *task, kpl_thread *thread); /* * Coroutine state object |
