aboutsummaryrefslogtreecommitdiff
path: root/odb/details/win32/once.ixx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/details/win32/once.ixx')
-rw-r--r--odb/details/win32/once.ixx30
1 files changed, 30 insertions, 0 deletions
diff --git a/odb/details/win32/once.ixx b/odb/details/win32/once.ixx
new file mode 100644
index 0000000..9f1706d
--- /dev/null
+++ b/odb/details/win32/once.ixx
@@ -0,0 +1,30 @@
+// file : odb/details/win32/once.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#include <odb/details/win32/lock.hxx>
+
+namespace odb
+{
+ namespace details
+ {
+ inline once::
+ once ()
+ : called_ (false)
+ {
+ }
+
+ inline void once::
+ call (void (*func) ())
+ {
+ win32_lock l (cs_);
+
+ if (!called_)
+ {
+ func ();
+ called_ = true;
+ }
+ }
+ }
+}