aboutsummaryrefslogtreecommitdiff
path: root/src/leveldb/port/port_win.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/leveldb/port/port_win.h')
-rw-r--r--src/leveldb/port/port_win.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/leveldb/port/port_win.h b/src/leveldb/port/port_win.h
index c9e1cdad60..849b01705f 100644
--- a/src/leveldb/port/port_win.h
+++ b/src/leveldb/port/port_win.h
@@ -93,8 +93,26 @@ class CondVar {
};
-typedef void* OnceType;
-#define LEVELDB_ONCE_INIT 0
+class OnceType {
+public:
+// OnceType() : init_(false) {}
+ OnceType(const OnceType &once) : init_(once.init_) {}
+ OnceType(bool f) : init_(f) {}
+ void InitOnce(void (*initializer)()) {
+ mutex_.Lock();
+ if (!init_) {
+ init_ = true;
+ initializer();
+ }
+ mutex_.Unlock();
+ }
+
+private:
+ bool init_;
+ Mutex mutex_;
+};
+
+#define LEVELDB_ONCE_INIT false
extern void InitOnce(port::OnceType*, void (*initializer)());
// Storage for a lock-free pointer