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 | e3c5ebca4152d1753f714c6b2d62485a2ef4d288 (patch) | |
| tree | 36de705cfb698c36e60c402d6e1dacd8e5616323 /qpid/cpp/include | |
| parent | 07f4175206b402e7745f58b831b0cf6ec1e26c2d (diff) | |
| download | qpid-python-e3c5ebca4152d1753f714c6b2d62485a2ef4d288.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@932517 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/include')
| -rw-r--r-- | qpid/cpp/include/qpid/management/ManagementObject.h | 4 | ||||
| -rw-r--r-- | qpid/cpp/include/qpid/management/Mutex.h | 66 |
2 files changed, 68 insertions, 2 deletions
diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h index 0e9c7f0a0b..9538a3e831 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/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/qpid/cpp/include/qpid/management/Mutex.h b/qpid/cpp/include/qpid/management/Mutex.h new file mode 100644 index 0000000000..ec1ff35402 --- /dev/null +++ b/qpid/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 + |
