Rate This Document
Findability
Accuracy
Completeness
Readability

kupl_queue_submit

Submit items to be executed to a queue.

Interface Definition

int kupl_queue_submit(kupl_queue_h queue, kupl_queue_item_desc_t *desc);

Parameters

Table 1 Parameter definition

Parameter

Type

Description

Input/Output

queue

kupl_queue_h

Queue for executing items

Input

desc

kupl_queue_item_desc_t

Description of a queue item

Input

Table 2 kupl_queue_item_desc_t data structure

Parameter

Type

Description

field_mask

uint64_t

Mask of valid fields in the structure, similar to the bit flag of kupl_queue_item_desc_field. Fields not specified in this mask will be ignored.

Options:

  • KUPL_QUEUE_ITEM_DESC_FIELD_NAME: name takes effect.
  • KUPL_QUEUE_ITEM_DESC_FIELD_EGROUP: egroup takes effect.
  • KUPL_QUEUE_ITEM_DESC_FIELD_ARGS_SIZE: args_size takes effect.

func

kupl_queue_item_func_t

Function pointer to a queue item

args

void *

Arguments of a queue item

name

const char *

Name of a queue item

egroup

kupl_egroup_h

Affinity information of a queue item

args_size

size_t

Size of the arguments to be copied

kupl_queue_item_func_t definition

void (*kupl_queue_item_func_t)(void *args);

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
#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 queue = kupl_queue_create();
    kupl_queue_item_desc_t desc = {
        .field_mask = KUPL_QUEUE_ITEM_DESC_FIELD_NAME,
        .func = kernel_func,
        .args = NULL,
        .name = "kernel_name"
    };
    int ret = kupl_queue_submit(queue, &desc); 
    assert(ret == KUPL_OK);
    kupl_queue_wait(queue);
    kupl_queue_destroy(queue);
    return 0;         
}

The execution result is as follows:

kernel exec.

The preceding example demonstrates the process of submitting items to a queue and waiting until all items in the queue are executed. The kupl_queue_submit is used to submit items to be executed to a queue.