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

kupl_egroup_borrow

Move all executor resources from the src egroup to the dest egroup.

Interface Definition

int kupl_egroup_borrow(kupl_egroup_h dest, kupl_egroup_h src);

Parameters

Table 1 Parameter definitions

Parameter

Type

Description

Input/Output

dest

kupl_egroup_h

egroup that needs to borrow the executors.

Input/Output

src

kupl_egroup_h

egroup that provides the executors

Input/Output

Return Value

  • Success: size of the dest egroup after borrowing the executors
  • 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 "kupl.h" 

int main() 
{ 
    int executor_num = kupl_get_num_executors(); 
    int n1 = executor_num / 2; 
    int n2 = executor_num - executor_num / 2;
    int executors1[n1], executors2[n2]; 
    for (int i =0; i < n1; i++) {
        executors1[i] = i;
    } 
    for (int i =0; i < n2; i++) {
        executors2[i] = i + n1;
    } 
    kupl_egroup_h egroup1 = kupl_egroup_create(executors1, n1); 
    kupl_egroup_h egroup2 = kupl_egroup_create(executors2, n2); 
    printf("egroup1 : %d executors\n", n1); 
    n1 = kupl_egroup_borrow(egroup1, egroup2); 
    printf("egroup1 : %d executors\n", n1); 
    kupl_egroup_destroy(egroup1); 
    kupl_egroup_destroy(egroup2); 
    return 0; 
}

The execution result is as follows:

egroup1 : 2 executors
egroup1 : 4 executors

The preceding example demonstrates how the created egroup1 borrows all executors from egroup2. The execution output prints both the initial and final executor counts for egroup1, indicating that the kupl_egroup_borrow function enables egroup1 to successfully obtain all executors from egroup2.