|
@@ -13,11 +13,14 @@
|
|
|
#ifdef WINDOWS_BUILD
|
|
|
#include <windows.h>
|
|
|
#elif LINUX_BUILD
|
|
|
-#include <fcntl.h>
|
|
|
+#include <sys/file.h>
|
|
|
#include <unistd.h>
|
|
|
#include <stdio.h>
|
|
|
#endif
|
|
|
-
|
|
|
+#ifdef SINGLETON
|
|
|
+#else
|
|
|
+#define SINGLETON(value) {v3::singleton single; if (single.locker(value)) return 0;}
|
|
|
+#endif // SINGLETON
|
|
|
namespace robotics {
|
|
|
namespace v3 {
|
|
|
class singleton {
|
|
@@ -31,7 +34,7 @@ namespace robotics {
|
|
|
#elif LINUX_BUILD
|
|
|
std::string file = "/tmp/" + value + ".lock";
|
|
|
fd_ = open(file.c_str(), O_CREAT | O_RDWR, 0666);
|
|
|
- return flock(fd, LOCK_EX | LOCK_NB) == -1;
|
|
|
+ return flock(fd_, LOCK_EX | LOCK_NB) == -1;
|
|
|
#endif
|
|
|
}
|
|
|
~singleton() {
|