Simplify the SmartMutex implementation a bit.
authorOwen Anderson <resistor@mac.com>
Thu, 18 Jun 2009 18:29:03 +0000 (18:29 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 18 Jun 2009 18:29:03 +0000 (18:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73711 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Mutex.h

index f749c5d70671dae0fae552b2053d9683e32926ff..d8a18865f68054529fa05b80ddd9b8ea9f41f618 100644 (file)
@@ -86,31 +86,30 @@ namespace llvm
     /// indicates whether this mutex should become a no-op when we're not
     /// running in multithreaded mode.
     template<bool mt_only>
-    class SmartMutex {
-      MutexImpl mtx;
+    class SmartMutex : public MutexImpl {
     public:
-      explicit SmartMutex(bool recursive = true) : mtx(recursive) { }
+      explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { }
       
       bool acquire() {
-        if (!mt_only || (mt_only && llvm_is_multithreaded()))
-          return mtx.acquire();
+        if (!mt_only && llvm_is_multithreaded())
+          return MutexImpl::acquire();
         return true;
       }
 
       bool release() {
-        if (!mt_only || (mt_only && llvm_is_multithreaded()))
-          return mtx.release();
+        if (!mt_only || llvm_is_multithreaded())
+          return MutexImpl::release();
         return true;
       }
 
       bool tryacquire() {
-        if (!mt_only || (mt_only && llvm_is_multithreaded()))
-          return mtx.tryacquire();
+        if (!mt_only || llvm_is_multithreaded())
+          return MutexImpl::tryacquire();
         return true;
       }
       
       private:
-        SmartMutex<mt_only>(const SmartMutex<mt_only> & original);
+        SmartMutex(const SmartMutex<mt_only> & original);
         void operator=(const SmartMutex<mt_only> &);
     };