我要评分
获取效率
正确性
完整性
易理解

kupl_graph_wait

Block further execution until all tasks within the KUPL graph have completed execution.

Interface Definition

void kupl_graph_wait(kupl_graph_h graph);

Parameters

Table 1 Parameter definition

Parameter

Type

Description

Input/Output

graph

kupl_graph_h

KUPL graph requiring a wait for all its tasks to complete execution.

Input

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
32
33
34
35
36
37
#include <stdio.h> 
#include "kupl.h" 
#include <assert.h>

static inline void task_str(void *args)
{
    printf("graph task test.\n");
}

int main() 
{ 
    int executor_num = kupl_get_num_executors(); 
    int executors[executor_num]; 
    for (int i = 0; i < executor_num; i++) {
        executors[i] = i;
    } 
    kupl_egroup_h egroup = kupl_egroup_create(executors, executor_num);
    kupl_graph_h graph = kupl_graph_create(egroup); 
    kupl_task_desc_t task_desc = {
        .field_mask = KUPL_TASK_DESC_FIELD_FLAG,
        .func = task_str,
        .args = NULL, 
        .flag = KUPL_TASK_FLAG_IMM,
    };
    kupl_task_info_t info = {
        .type = KUPL_TASK_TYPE_SINGLE,
        .desc = &task_desc,
    };

    int ret = kupl_graph_submit(graph, &info);
    assert(ret == KUPL_OK);

    kupl_graph_wait(graph);
    kupl_graph_destroy(graph);
    kupl_egroup_destroy(egroup);
    return 0;         
}

The execution result is as follows:

graph task test.

The preceding example demonstrates how to submit a task to a graph and wait for the completion of all tasks within that graph. The preceding kupl_graph_wait function blocks further execution until all tasks in the graph are fully executed.