File: event_base_frame.c

package info (click to toggle)
openmpi 3.1.3-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,572 kB
  • sloc: ansic: 628,972; f90: 17,993; makefile: 13,761; sh: 7,051; java: 6,360; perl: 3,215; cpp: 2,225; python: 1,350; lex: 988; fortran: 52; tcl: 12
file content (110 lines) | stat: -rw-r--r-- 2,939 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * Copyright (c) 2010-2015 Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
 * Copyright (c) 2017      Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */


#include "opal_config.h"

#include "opal/constants.h"
#include "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"

#include "opal/mca/event/event.h"
#include "opal/mca/event/base/base.h"


/*
 * The following file was created by configure.  It contains extern
 * statements and the definition of an array of pointers to each
 * component's public mca_base_component_t struct.
 */
#include "opal/mca/event/base/static-components.h"

/**
 * Initialize the event MCA framework
 *
 * @retval OPAL_SUCCESS Upon success
 * @retval OPAL_ERROR Upon failure
 *
 * This must be the first function invoked in the event MCA
 * framework.  It initializes the event MCA framework, finds
 * and opens event components, etc.
 *
 * This function is invoked during opal_init().
 *
 * This function fills in the internal global variable
 * opal_event_base_components_opened, which is a list of all
 * event components that were successfully opened.  This
 * variable should \em only be used by other event base
 * functions -- it is not considered a public interface member --
 * and is only mentioned here for completeness.
 */
static int opal_event_base_open(mca_base_open_flag_t flags);
static int opal_event_base_close(void);

/* Use default register and close function */
MCA_BASE_FRAMEWORK_DECLARE(opal, event, NULL, NULL, opal_event_base_open,
			   opal_event_base_close, mca_event_base_static_components,
			   0);

/*
 * Globals
 */
opal_event_base_t *opal_sync_event_base=NULL;

static int opal_event_base_open(mca_base_open_flag_t flags)
{
    int rc = OPAL_SUCCESS;

    /* Silence compiler warning */
    (void) flags;

    /* no need to open the components since we only use one */

    /* init the lib */
    if (OPAL_SUCCESS != (rc = opal_event_init())) {
        return rc;
    }

    /* Declare our intent to use threads */
    opal_event_use_threads();

    /* get our event base */
    if (NULL == (opal_sync_event_base = opal_event_base_create())) {
        return OPAL_ERROR;
    }

    /* set the number of priorities */
    if (0 < OPAL_EVENT_NUM_PRI) {
        opal_event_base_priority_init(opal_sync_event_base, OPAL_EVENT_NUM_PRI);
    }

    return rc;
}

static int opal_event_base_close(void)
{
    int rc;
    
    /* cleanup components even though they are statically opened */
    if (OPAL_SUCCESS != (rc =mca_base_framework_components_close (&opal_event_base_framework,
						                  NULL))) {
        return rc;
    }

    opal_event_base_free(opal_sync_event_base);

    /* finalize the lib */
    return opal_event_finalize();

}