aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/simple-object-statements.ixx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/pgsql/simple-object-statements.ixx')
-rw-r--r--odb/pgsql/simple-object-statements.ixx69
1 files changed, 69 insertions, 0 deletions
diff --git a/odb/pgsql/simple-object-statements.ixx b/odb/pgsql/simple-object-statements.ixx
new file mode 100644
index 0000000..6f2d209
--- /dev/null
+++ b/odb/pgsql/simple-object-statements.ixx
@@ -0,0 +1,69 @@
+// file : odb/pgsql/simple-object-statements.ixx
+// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+namespace odb
+{
+ namespace pgsql
+ {
+ //
+ // auto_unlock
+ //
+ inline object_statements_base::auto_unlock::
+ auto_unlock (object_statements_base& s)
+ : s_ (s)
+ {
+ s_.unlock ();
+ }
+
+ inline object_statements_base::auto_unlock::
+ ~auto_unlock ()
+ {
+ s_.lock ();
+ }
+
+ //
+ // auto_lock
+ //
+ template <typename T>
+ inline object_statements<T>::auto_lock::
+ auto_lock (object_statements& s)
+ : s_ (s)
+ {
+ if (!s_.locked ())
+ {
+ s_.lock ();
+ locked_ = true;
+ }
+ else
+ locked_ = false;
+ }
+
+ template <typename T>
+ inline object_statements<T>::auto_lock::
+ ~auto_lock ()
+ {
+ if (locked_)
+ {
+ s_.unlock ();
+ s_.clear_delayed ();
+ }
+ }
+
+ template <typename T>
+ inline bool object_statements<T>::auto_lock::
+ locked () const
+ {
+ return locked_;
+ }
+
+ template <typename T>
+ inline void object_statements<T>::auto_lock::
+ unlock ()
+ {
+ assert (locked_);
+ s_.unlock ();
+ locked_ = false;
+ }
+ }
+}