This source file includes following definitions.
- ompi_peruse_handle_construct
- ompi_peruse_handle_destruct
- ompi_peruse_init
- ompi_peruse_finalize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include "ompi_config.h"
16 # include <stdlib.h>
17 #include "mpi.h"
18 #include "ompi/peruse/peruse.h"
19 #include "ompi/peruse/peruse-internal.h"
20 #include "ompi/constants.h"
21
22 static opal_list_t peruse_handle_list;
23 static opal_mutex_t peruse_handle_list_lock;
24 int ompi_peruse_initialized = 0;
25 int ompi_peruse_finalized = 0;
26
27 static void ompi_peruse_handle_construct (ompi_peruse_handle_t* p)
28 {
29 OBJ_CONSTRUCT (&(p->lock), opal_mutex_t);
30 p->active = 0;
31 p->event = PERUSE_EVENT_INVALID;
32 p->type = PERUSE_TYPE_INVALID;
33 p->comm = MPI_COMM_NULL;
34
35
36 p->fn = NULL;
37 p->param = NULL;
38
39 OPAL_THREAD_LOCK (&peruse_handle_list_lock);
40 opal_list_append (&peruse_handle_list, (opal_list_item_t*)p);
41 OPAL_THREAD_UNLOCK (&peruse_handle_list_lock);
42 }
43
44 static void ompi_peruse_handle_destruct (ompi_peruse_handle_t* p)
45 {
46 OPAL_THREAD_LOCK (&peruse_handle_list_lock);
47 opal_list_remove_item (&peruse_handle_list, (opal_list_item_t*)p);
48 OPAL_THREAD_UNLOCK (&peruse_handle_list_lock);
49
50 OBJ_DESTRUCT (&(p->lock));
51 }
52
53 OBJ_CLASS_INSTANCE(
54 ompi_peruse_handle_t,
55 opal_list_item_t,
56 ompi_peruse_handle_construct,
57 ompi_peruse_handle_destruct);
58
59
60 int ompi_peruse_init (void)
61 {
62 if (ompi_peruse_initialized)
63 return OMPI_SUCCESS;
64 ompi_peruse_initialized = 1;
65
66 OBJ_CONSTRUCT (&peruse_handle_list, opal_list_t);
67 OBJ_CONSTRUCT (&peruse_handle_list_lock, opal_mutex_t);
68
69 return OMPI_SUCCESS;
70 }
71
72
73 int ompi_peruse_finalize (void)
74 {
75 if (!ompi_peruse_initialized)
76 return OMPI_SUCCESS;
77
78 ompi_peruse_finalized = 1;
79
80 OBJ_DESTRUCT (&peruse_handle_list);
81 OBJ_DESTRUCT (&peruse_handle_list_lock);
82
83 return OMPI_SUCCESS;
84 }
85