diff options
| author | Ted Ross <tross@apache.org> | 2010-04-09 17:19:32 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2010-04-09 17:19:32 +0000 |
| commit | 3e19793c8f5be1676ea6f7577196f1b01cadf685 (patch) | |
| tree | 5d36d56405507f9c68736a4299f21dea294b99f5 /cpp/include | |
| parent | fcfff56e615c4054d52dc510c9cd1d1103249dce (diff) | |
| download | qpid-python-3e19793c8f5be1676ea6f7577196f1b01cadf685.tar.gz | |
QPID-2489 - Added wrapped version of Mutex to isolate QMF-generated source from boost.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@932517 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include')
| -rw-r--r-- | cpp/include/qpid/management/ManagementObject.h | 4 | ||||
| -rw-r--r-- | cpp/include/qpid/management/Mutex.h | 66 |
2 files changed, 68 insertions, 2 deletions
diff --git a/cpp/include/qpid/management/ManagementObject.h b/cpp/include/qpid/management/ManagementObject.h index 0e9c7f0a0b..9538a3e831 100644 --- a/cpp/include/qpid/management/ManagementObject.h +++ b/cpp/include/qpid/management/ManagementObject.h @@ -23,7 +23,7 @@ */ #include "qpid/sys/Time.h" -#include "qpid/sys/Mutex.h" +#include "qpid/management/Mutex.h" #include "qpid/CommonImportExport.h" #include "qpid/types/Variant.h" #include <map> @@ -139,7 +139,7 @@ protected: mutable bool instChanged; bool deleted; Manageable* coreObject; - mutable sys::Mutex accessLock; + mutable Mutex accessLock; uint32_t flags; static int nextThreadIndex; diff --git a/cpp/include/qpid/management/Mutex.h b/cpp/include/qpid/management/Mutex.h new file mode 100644 index 0000000000..ec1ff35402 --- /dev/null +++ b/cpp/include/qpid/management/Mutex.h @@ -0,0 +1,66 @@ +#ifndef _management_Mutex_h +#define _management_Mutex_h + +/* + * + * Copyright (c) 2008 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +namespace qpid { + namespace sys { + class Mutex; + } + + namespace management { + + /** + * Scoped lock template: calls lock() in ctor, unlock() in dtor. + * L can be any class with lock() and unlock() functions. + */ + template <class L> class ScopedLockTemplate { + public: + ScopedLockTemplate(L& l) : mutex(l) { mutex.lock(); } + ~ScopedLockTemplate() { mutex.unlock(); } + private: + L& mutex; + }; + + template <class L> class ScopedUnlockTemplate { + public: + ScopedUnlockTemplate(L& l) : mutex(l) { mutex.unlock(); } + ~ScopedUnlockTemplate() { mutex.lock(); } + private: + L& mutex; + }; + + class Mutex { + public: + typedef ScopedLockTemplate<Mutex> ScopedLock; + typedef ScopedUnlockTemplate<Mutex> ScopedUnlock; + + Mutex(); + ~Mutex(); + void lock(); + void unlock(); + private: + sys::Mutex* impl; + }; + } +} + +#endif + |
