kupl_queue_wait_event
Synchronize a queue with an event. This function is often used for synchronization between two queues.
Interface Definition
int kupl_queue_wait_event(kupl_queue_h queue, kupl_event_h event);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
queue |
kupl_queue_h |
Queue to be synchronized |
Input |
event |
kupl_event_h |
Event to be synchronized |
Input |
Return Value
Success: KUPL_OK
Failure: KUPL_ERROR
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <stdio.h> #include <assert.h> #include "kupl.h" static inline void kernel_func(void *args) { printf("kernel exec.\n"); } int main() { kupl_queue_h q1 = kupl_queue_create(); kupl_queue_h q2 = kupl_queue_create(); kupl_event_h event = kupl_event_create(); kupl_queue_item_desc_t desc = { .field_mask = KUPL_QUEUE_ITEM_DESC_FIELD_NAME, .func = kernel_func, .args = NULL, .name = "kernel_name" }; kupl_queue_submit(q1, &desc); kupl_event_record(event, q1); int ret = kupl_queue_wait_event(q2, event); assert(ret == KUPL_OK); kupl_event_destroy(event); kupl_queue_destroy(q2); kupl_queue_destroy(q1); return 0; } |
The execution result is as follows:
kernel exec.
The preceding example demonstrates the process of submitting items to q1 and synchronizing q1 and q2. The kupl_queue_wait_event function continues execution until the items in q1 are executed.
Parent topic: Multi-queue Multi-stream Programming Functions