summaryrefslogtreecommitdiff
path: root/port/port_example.h
diff options
context:
space:
mode:
Diffstat (limited to 'port/port_example.h')
-rw-r--r--port/port_example.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/port/port_example.h b/port/port_example.h
index 036c7d1..ab9e489 100644
--- a/port/port_example.h
+++ b/port/port_example.h
@@ -60,6 +60,16 @@ class CondVar {
void SignallAll();
};
+// Thread-safe initialization.
+// Used as follows:
+// static port::OnceType init_control = LEVELDB_ONCE_INIT;
+// static void Initializer() { ... do something ...; }
+// ...
+// port::InitOnce(&init_control, &Initializer);
+typedef intptr_t OnceType;
+#define LEVELDB_ONCE_INIT 0
+extern void InitOnce(port::OnceType*, void (*initializer)());
+
// A type that holds a pointer that can be read or written atomically
// (i.e., without word-tearing.)
class AtomicPointer {