diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2015-01-23 00:46:41 -0800 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2015-01-23 00:46:41 -0800 |
commit | 2bab15f431bec4ba5f10238e6f578ab2653ea675 (patch) | |
tree | 3dd78f995fb1f801e3f57fc019da1f8200c244ab /src/core/abstract | |
parent | d45ce14d841e6555bf0b524cee12aa111155ffab (diff) |
Use spinlock
Diffstat (limited to 'src/core/abstract')
-rw-r--r-- | src/core/abstract/MCMessageHeader.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/abstract/MCMessageHeader.cpp b/src/core/abstract/MCMessageHeader.cpp index bc141424..e65695ca 100644 --- a/src/core/abstract/MCMessageHeader.cpp +++ b/src/core/abstract/MCMessageHeader.cpp @@ -6,6 +6,7 @@ #include "MCAddress.h" #include "MCIterator.h" #include "MCLibetpan.h" +#include "MCLock.h" #include <string.h> #ifndef _MSC_VER @@ -76,9 +77,9 @@ void MessageHeader::init(bool generateDate, bool generateMessageID) } if (generateMessageID) { static String * hostname = NULL; - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + static MC_LOCK_TYPE lock = MC_LOCK_INITIAL_VALUE; - pthread_mutex_lock(&lock); + MC_LOCK(&lock); if (hostname == NULL) { char name[MAX_HOSTNAME]; int r; @@ -94,7 +95,7 @@ void MessageHeader::init(bool generateDate, bool generateMessageID) hostname = new String("localhost"); } } - pthread_mutex_unlock(&lock); + MC_UNLOCK(&lock); String * messageID = new String(); messageID->appendString(String::uuidString()); |