11/*
22 * Copyright (c) 2014-2019 Intel, Inc. All rights reserved.
3+ * Copyright (c) 2020 Triad National Security, LLC. All rights
4+ * reserved.
35 * $COPYRIGHT$
46 *
57 * Additional copyrights may follow
@@ -35,21 +37,8 @@ OPAL_DECLSPEC int opal_pmix_base_exchange(pmix_info_t *info,
3537 pmix_pdata_t * pdat ,
3638 int timeout );
3739
38- OPAL_DECLSPEC void opal_pmix_base_set_evbase (opal_event_base_t * evbase );
39-
40- #define opal_pmix_condition_wait (a ,b ) opal_cond_wait(a, b)
41- typedef opal_cond_t opal_pmix_condition_t ;
42- #define opal_pmix_condition_broadcast (a ) opal_cond_broadcast(a)
4340#define opal_pmix_condition_signal (a ) opal_cond_signal(a)
4441
45- typedef struct {
46- opal_mutex_t mutex ;
47- opal_pmix_condition_t cond ;
48- volatile bool active ;
49- int status ;
50- } opal_pmix_lock_t ;
51-
52-
5342typedef struct {
5443 opal_event_base_t * evbase ;
5544 int timeout ;
@@ -60,112 +49,6 @@ typedef struct {
6049extern opal_pmix_base_t opal_pmix_base ;
6150
6251#define OPAL_PMIX_CONDITION_STATIC_INIT PTHREAD_COND_INITIALIZER
63- #define OPAL_PMIX_CONSTRUCT_LOCK (l ) \
64- do { \
65- OBJ_CONSTRUCT(&(l)->mutex, opal_mutex_t); \
66- opal_cond_init(&(l)->cond); \
67- (l)->active = true; \
68- OPAL_POST_OBJECT((l)); \
69- } while(0)
70-
71- #define OPAL_PMIX_DESTRUCT_LOCK (l ) \
72- do { \
73- OPAL_ACQUIRE_OBJECT((l)); \
74- OBJ_DESTRUCT(&(l)->mutex); \
75- opal_cond_destroy(&(l)->cond); \
76- } while(0)
77-
78-
79- #if OPAL_ENABLE_DEBUG
80- #define OPAL_PMIX_ACQUIRE_THREAD (lck ) \
81- do { \
82- opal_mutex_lock(&(lck)->mutex); \
83- if (opal_debug_threads) { \
84- opal_output(0, "Waiting for thread %s:%d", \
85- __FILE__, __LINE__); \
86- } \
87- while ((lck)->active) { \
88- opal_pmix_condition_wait(&(lck)->cond, &(lck)->mutex); \
89- } \
90- if (opal_debug_threads) { \
91- opal_output(0, "Thread obtained %s:%d", \
92- __FILE__, __LINE__); \
93- } \
94- (lck)->active = true; \
95- } while(0)
96- #else
97- #define OPAL_PMIX_ACQUIRE_THREAD (lck ) \
98- do { \
99- opal_mutex_lock(&(lck)->mutex); \
100- while ((lck)->active) { \
101- opal_pmix_condition_wait(&(lck)->cond, &(lck)->mutex); \
102- } \
103- (lck)->active = true; \
104- } while(0)
105- #endif
106-
107-
108- #if OPAL_ENABLE_DEBUG
109- #define OPAL_PMIX_WAIT_THREAD (lck ) \
110- do { \
111- opal_mutex_lock(&(lck)->mutex); \
112- if (opal_debug_threads) { \
113- opal_output(0, "Waiting for thread %s:%d", \
114- __FILE__, __LINE__); \
115- } \
116- while ((lck)->active) { \
117- opal_pmix_condition_wait(&(lck)->cond, &(lck)->mutex); \
118- } \
119- if (opal_debug_threads) { \
120- opal_output(0, "Thread obtained %s:%d", \
121- __FILE__, __LINE__); \
122- } \
123- OPAL_ACQUIRE_OBJECT(&lck); \
124- opal_mutex_unlock(&(lck)->mutex); \
125- } while(0)
126- #else
127- #define OPAL_PMIX_WAIT_THREAD (lck ) \
128- do { \
129- opal_mutex_lock(&(lck)->mutex); \
130- while ((lck)->active) { \
131- opal_pmix_condition_wait(&(lck)->cond, &(lck)->mutex); \
132- } \
133- OPAL_ACQUIRE_OBJECT(lck); \
134- opal_mutex_unlock(&(lck)->mutex); \
135- } while(0)
136- #endif
137-
138-
139- #if OPAL_ENABLE_DEBUG
140- #define OPAL_PMIX_RELEASE_THREAD (lck ) \
141- do { \
142- if (opal_debug_threads) { \
143- opal_output(0, "Releasing thread %s:%d", \
144- __FILE__, __LINE__); \
145- } \
146- (lck)->active = false; \
147- opal_pmix_condition_broadcast(&(lck)->cond); \
148- opal_mutex_unlock(&(lck)->mutex); \
149- } while(0)
150- #else
151- #define OPAL_PMIX_RELEASE_THREAD (lck ) \
152- do { \
153- assert(0 != opal_mutex_trylock(&(lck)->mutex)); \
154- (lck)->active = false; \
155- opal_pmix_condition_broadcast(&(lck)->cond); \
156- opal_mutex_unlock(&(lck)->mutex); \
157- } while(0)
158- #endif
159-
160-
161- #define OPAL_PMIX_WAKEUP_THREAD (lck ) \
162- do { \
163- opal_mutex_lock(&(lck)->mutex); \
164- (lck)->active = false; \
165- OPAL_POST_OBJECT(lck); \
166- opal_pmix_condition_broadcast(&(lck)->cond); \
167- opal_mutex_unlock(&(lck)->mutex); \
168- } while(0)
16952
17053END_C_DECLS
17154
0 commit comments