3131#include "opal/mca/threads/mutex.h"
3232//#include "opal/mca/threads/pthreads/mutex_unix.h"
3333
34-
35- OBJ_CLASS_INSTANCE (opal_mutex_t ,
36- opal_object_t ,
37- NULL ,
38- NULL );
39- OBJ_CLASS_INSTANCE (opal_recursive_mutex_t ,
40- opal_object_t ,
41- NULL ,
42- NULL );
43-
4434/*
4535 * Wait and see if some upper layer wants to use threads, if support
4636 * exists.
@@ -63,3 +53,46 @@ struct opal_pthread_mutex_t {
6353typedef struct opal_pthread_mutex_t opal_pthread_mutex_t ;
6454typedef struct opal_pthread_mutex_t opal_pthread_recursive_mutex_t ;
6555
56+ static void mca_threads_pthreads_mutex_constructor (opal_mutex_t * p_mutex ) {
57+ pthread_mutex_init (& p_mutex -> m_lock_pthread , NULL );
58+ #if OPAL_ENABLE_DEBUG
59+ p_mutex -> m_lock_debug = 0 ;
60+ p_mutex -> m_lock_file = NULL ;
61+ p_mutex -> m_lock_line = 0 ;
62+ #endif
63+ opal_atomic_lock_init (& p_mutex -> m_lock_atomic , 0 );
64+ }
65+
66+ static void mca_threads_pthreads_mutex_desctructor (opal_mutex_t * p_mutex ) {
67+ pthread_mutex_destroy (& p_mutex -> m_lock_pthread );
68+ }
69+
70+ static void mca_threads_pthreads_recursive_mutex_constructor
71+ (opal_recursive_mutex_t * p_mutex ) {
72+ pthread_mutexattr_t mutex_attr ;
73+ pthread_mutexattr_init (& mutex_attr );
74+ pthread_mutexattr_settype (& mutex_attr , PTHREAD_MUTEX_RECURSIVE );
75+ pthread_mutex_init (& p_mutex -> m_lock_pthread , & mutex_attr );
76+ pthread_mutexattr_destroy (& mutex_attr );
77+ #if OPAL_ENABLE_DEBUG
78+ p_mutex -> m_lock_debug = 0 ;
79+ p_mutex -> m_lock_file = NULL ;
80+ p_mutex -> m_lock_line = 0 ;
81+ #endif
82+ opal_atomic_lock_init (& p_mutex -> m_lock_atomic , 0 );
83+ }
84+
85+ static void mca_threads_pthreads_recursive_mutex_desctructor
86+ (opal_recursive_mutex_t * p_mutex ) {
87+ pthread_mutex_destroy (& p_mutex -> m_lock_pthread );
88+ }
89+
90+ OBJ_CLASS_INSTANCE (opal_mutex_t ,
91+ opal_object_t ,
92+ mca_threads_pthreads_mutex_constructor ,
93+ mca_threads_pthreads_mutex_desctructor );
94+
95+ OBJ_CLASS_INSTANCE (opal_recursive_mutex_t ,
96+ opal_object_t ,
97+ mca_threads_pthreads_recursive_mutex_constructor ,
98+ mca_threads_pthreads_recursive_mutex_desctructor );
0 commit comments