Task::Queue for mruby/c. More...
Go to the source code of this file.
Functions | |
| static int | queue_wake_one_waiter (void *q) |
| static int | queue_wake_all_waiters (void *q) |
| static int | queue_is_closed (mrbc_value *queue) |
| void | mrbc_init_task_queue (void) |
| mrbc_task_queue_push_result | mrbc_task_queue_push (mrbc_value *queue, mrbc_value *value) |
Variables | |
| static mrbc_value | wait_retry_ |
| static mrbc_value | wait_timeout_ |
| static struct RClass * | task_error_class_ |
| static mrbc_sym | sym_items_ |
| static mrbc_sym | sym_closed_ |
Task::Queue for mruby/c.
Copyright (C) 2026- HASUMI Hitoshi This file is distributed under BSD 3-Clause License.
Definition in file c_task_queue.c.
| void mrbc_init_task_queue | ( | void | ) |
initialize
Definition at line 398 of file c_task_queue.c.
| mrbc_task_queue_push_result mrbc_task_queue_push | ( | mrbc_value * | queue, |
| mrbc_value * | value ) |
Push a value into a Task::Queue from C and wake one waiting task.
Ownership of value stays with the caller; the queue takes its own reference. An invalid receiver and a closed queue are reported as a result code rather than an exception, so this is usable where no VM context is at hand.
(NOTE) This grows the item array through the mruby/c allocator and edits the task queues, so it must NOT be called from an interrupt handler, nor from any context that could re-enter the VM. There is no portable way to detect that at run time, so the caller is responsible for honouring it. To feed a queue from an interrupt, buffer the data in an ISR-safe ring buffer and push it from a task.
A caller running inside the VM must set flag_preemption when MRBC_TASK_QUEUE_PUSH_OK_WOKE is returned, otherwise the woken task waits for the current time slice to expire. See c_task_queue_push().
| queue | Task::Queue instance (or an instance of its subclass). |
| value | value to push. |
Definition at line 441 of file c_task_queue.c.
|
static |
Check whether the queue has been closed.
(NOTE) @closed only ever holds true or false, so the decref is a no-op in practice. It is kept to stay paired with the incref done by mrbc_instance_getiv().
| queue | Task::Queue instance. |
Definition at line 123 of file c_task_queue.c.
|
static |
Wake all tasks waiting on this queue (used by close).
| q | Queue instance the tasks are waiting on. |
Definition at line 88 of file c_task_queue.c.
|
static |
Wake the highest-priority task waiting on this queue.
| q | Queue instance the tasks are waiting on. |
Definition at line 59 of file c_task_queue.c.
|
static |
Definition at line 47 of file c_task_queue.c.
|
static |
Definition at line 46 of file c_task_queue.c.
|
static |
Definition at line 43 of file c_task_queue.c.
|
static |
Definition at line 34 of file c_task_queue.c.
|
static |
Definition at line 40 of file c_task_queue.c.