Add scoped_ptr support to Lock wrappers
authorScott Cantor <cantor.2@osu.edu>
Thu, 29 Dec 2011 22:55:08 +0000 (22:55 +0000)
committerScott Cantor <cantor.2@osu.edu>
Thu, 29 Dec 2011 22:55:08 +0000 (22:55 +0000)
configure.ac
cpp-xmltooling.sln
xmltooling/util/Threads.h

index 68688b7..7a2f21b 100644 (file)
@@ -99,6 +99,7 @@ BOOST_BIND
 BOOST_CONVERSION
 BOOST_LAMBDA
 BOOST_PTR_CONTAINER
+BOOST_SMART_PTR
 BOOST_STRING_ALGO
 BOOST_TOKENIZER
 CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
index 872535b..db674e9 100644 (file)
@@ -6,7 +6,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{61BF324D-2
                m4\acinclude.m4 = m4\acinclude.m4\r
                m4\acx_pthread.m4 = m4\acx_pthread.m4\r
                m4\ax_create_pkgconfig_info.m4 = m4\ax_create_pkgconfig_info.m4\r
-               ..\cpp-sp-ext\m4\boost.m4 = ..\cpp-sp-ext\m4\boost.m4\r
+               m4\boost.m4 = m4\boost.m4\r
                config_win32.h = config_win32.h\r
                configure.ac = configure.ac\r
                doxygen.am = doxygen.am\r
index 5269763..63e4c54 100644 (file)
@@ -30,6 +30,7 @@
 #include <xmltooling/exceptions.h>
 
 #include <memory>
+#include <boost/scoped_ptr.hpp>
 #include <signal.h>
 
 namespace xmltooling
@@ -310,7 +311,17 @@ namespace xmltooling
          *
          * @param mtx mutex to lock
          */
-        Lock(std::auto_ptr<Mutex>& mtx) : mutex(mtx.get()) {
+        Lock(const std::auto_ptr<Mutex>& mtx) : mutex(mtx.get()) {
+            if (mutex)
+                mutex->lock();
+        }
+
+        /**
+         * Locks and wraps the designated mutex.
+         *
+         * @param mtx mutex to lock
+         */
+        Lock(const boost::scoped_ptr<Mutex>& mtx) : mutex(mtx.get()) {
             if (mutex)
                 mutex->lock();
         }
@@ -350,7 +361,18 @@ namespace xmltooling
          * @param lock      lock to acquire
          * @param lockit    true if the lock should be acquired here, false if already acquired
          */
-        SharedLock(std::auto_ptr<RWLock>& lock, bool lockit=true) : rwlock(lock.get()) {
+        SharedLock(const std::auto_ptr<RWLock>& lock, bool lockit=true) : rwlock(lock.get()) {
+            if (rwlock && lockit)
+                rwlock->rdlock();
+        }
+
+        /**
+         * Locks and wraps the designated shared lock.
+         *
+         * @param lock      lock to acquire
+         * @param lockit    true if the lock should be acquired here, false if already acquired
+         */
+        SharedLock(const boost::scoped_ptr<RWLock>& lock, bool lockit=true) : rwlock(lock.get()) {
             if (rwlock && lockit)
                 rwlock->rdlock();
         }