nrnmutdec.h

Go to the documentation of this file.
00001 #ifndef nrnmutdec_h
00002 #define nrnmutdec_h
00003 
00004 #include <nrnpthread.h>
00005 #if USE_PTHREAD
00006 #include <pthread.h>
00007 #define MUTDEC pthread_mutex_t* mut_;
00008 #define MUTCONSTRUCTED (mut_ != (pthread_mutex_t*)0)
00009 #if defined(__cplusplus)
00010 #define MUTCONSTRUCT(mkmut) {if (mkmut) {mut_ = new pthread_mutex_t; pthread_mutex_init(mut_, 0);}else{mut_ = 0;}}
00011 #define MUTDESTRUCT {if (mut_){pthread_mutex_destroy(mut_); delete mut_; mut_ = (pthread_mutex_t*)0;}}
00012 #else
00013 #define MUTCONSTRUCT(mkmut) {if (mkmut) {mut_ = (pthread_mutex_t*)malloc(sizeof(pthread_mutex_t)); pthread_mutex_init(mut_, 0);}else{mut_ = 0;}}
00014 #define MUTDESTRUCT {if (mut_){pthread_mutex_destroy(mut_); free((char*)mut_); mut_ = (pthread_mutex_t*)0;}}
00015 #endif
00016 #define MUTLOCK {if (mut_) {pthread_mutex_lock(mut_);}}
00017 #define MUTUNLOCK {if (mut_) {pthread_mutex_unlock(mut_);}}
00018 /*#define MUTLOCK {if (mut_) {printf("lock %lx\n", mut_); pthread_mutex_lock(mut_);}}*/
00019 /*#define MUTUNLOCK {if (mut_) {printf("unlock %lx\n", mut_); pthread_mutex_unlock(mut_);}}*/
00020 #else
00021 #define MUTDEC 
00022 #define MUTCONSTRUCTED (0)
00023 #define MUTCONSTRUCT(mkmut) 
00024 #define MUTDESTRUCT 
00025 #define MUTLOCK 
00026 #define MUTUNLOCK 
00027 #endif
00028 
00029 #endif
Generated on Mon Jun 13 08:10:24 2011 for NEURON by  doxygen 1.6.3