This source file includes following definitions.
- opal_mutex_construct
- opal_mutex_destruct
- opal_recursive_mutex_construct
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 #include "opal_config.h"
  25 
  26 #include "opal/threads/mutex.h"
  27 
  28 
  29 
  30 
  31 
  32 bool opal_uses_threads = false;
  33 
  34 static void opal_mutex_construct(opal_mutex_t *m)
  35 {
  36 #if OPAL_ENABLE_DEBUG
  37     pthread_mutexattr_t attr;
  38     pthread_mutexattr_init(&attr);
  39 
  40     
  41 #if OPAL_HAVE_PTHREAD_MUTEX_ERRORCHECK_NP
  42     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
  43 #elif OPAL_HAVE_PTHREAD_MUTEX_ERRORCHECK
  44     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
  45 #endif 
  46 
  47     pthread_mutex_init(&m->m_lock_pthread, &attr);
  48     pthread_mutexattr_destroy(&attr);
  49 
  50     m->m_lock_debug = 0;
  51     m->m_lock_file = NULL;
  52     m->m_lock_line = 0;
  53 #else
  54 
  55     
  56     pthread_mutex_init(&m->m_lock_pthread, NULL);
  57 
  58 #endif 
  59 
  60 #if OPAL_HAVE_ATOMIC_SPINLOCKS
  61     opal_atomic_lock_init( &m->m_lock_atomic, OPAL_ATOMIC_LOCK_UNLOCKED );
  62 #endif
  63 }
  64 
  65 static void opal_mutex_destruct(opal_mutex_t *m)
  66 {
  67     pthread_mutex_destroy(&m->m_lock_pthread);
  68 }
  69 
  70 OBJ_CLASS_INSTANCE(opal_mutex_t,
  71                    opal_object_t,
  72                    opal_mutex_construct,
  73                    opal_mutex_destruct);
  74 
  75 static void opal_recursive_mutex_construct(opal_recursive_mutex_t *m)
  76 {
  77     pthread_mutexattr_t attr;
  78     pthread_mutexattr_init(&attr);
  79 
  80 #if OPAL_ENABLE_DEBUG
  81     m->m_lock_debug = 0;
  82     m->m_lock_file = NULL;
  83     m->m_lock_line = 0;
  84 #endif
  85 
  86     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  87 
  88     pthread_mutex_init(&m->m_lock_pthread, &attr);
  89     pthread_mutexattr_destroy(&attr);
  90 
  91 #if OPAL_HAVE_ATOMIC_SPINLOCKS
  92     opal_atomic_lock_init( &m->m_lock_atomic, OPAL_ATOMIC_LOCK_UNLOCKED );
  93 #endif
  94 }
  95 
  96 OBJ_CLASS_INSTANCE(opal_recursive_mutex_t,
  97                    opal_object_t,
  98                    opal_recursive_mutex_construct,
  99                    opal_mutex_destruct);