summaryrefslogtreecommitdiffstats
path: root/src/uscxml/util/UUID.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/util/UUID.cpp')
-rw-r--r--src/uscxml/util/UUID.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/uscxml/util/UUID.cpp b/src/uscxml/util/UUID.cpp
index 6f7cf96..bc63ecd 100644
--- a/src/uscxml/util/UUID.cpp
+++ b/src/uscxml/util/UUID.cpp
@@ -20,6 +20,7 @@
#include <sstream>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/random_generator.hpp>
+#include <mutex>
#include "UUID.h"
@@ -27,8 +28,13 @@ namespace uscxml {
// hide from public header
boost::uuids::random_generator uuidGen;
+std::mutex uuidMutex;
std::string UUID::getUUID() {
+ // boost.random objects are not guaranteed to be thread-safe
+ // see issue 131
+ std::lock_guard<std::mutex> lock(uuidMutex);
+
boost::uuids::uuid uuid = uuidGen();
std::ostringstream os;
os << uuid;
@@ -71,4 +77,4 @@ bool UUID::isUUID(const std::string& uuid) {
return true;
}
-} \ No newline at end of file
+}