Add a pair of convenience macros for handling threads to minimize code duplication
This commit was SVN r22861.
Этот коммит содержится в:
родитель
f01f70b8f6
Коммит
df2d361b2b
@ -28,6 +28,8 @@
|
||||
#endif
|
||||
|
||||
#include "opal/class/opal_object.h"
|
||||
#include "mutex.h"
|
||||
#include "condition.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
@ -58,6 +60,23 @@ typedef struct opal_thread_t opal_thread_t;
|
||||
|
||||
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_thread_t);
|
||||
|
||||
#define OPAL_ACQUIRE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
OPAL_THREAD_LOCK((lck)); \
|
||||
while (*(act)) { \
|
||||
opal_condition_wait((cnd), (lck)); \
|
||||
} \
|
||||
*(act) = true; \
|
||||
} while(0);
|
||||
|
||||
#define OPAL_RELEASE_THREAD(lck, cnd, act) \
|
||||
do { \
|
||||
*(act) = false; \
|
||||
opal_condition_broadcast((cnd)); \
|
||||
OPAL_THREAD_UNLOCK((lck)); \
|
||||
} while(0);
|
||||
|
||||
|
||||
OPAL_DECLSPEC int opal_thread_start(opal_thread_t *);
|
||||
OPAL_DECLSPEC int opal_thread_join(opal_thread_t *, void **thread_return);
|
||||
OPAL_DECLSPEC bool opal_thread_self_compare(opal_thread_t*);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user