diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-03-17 14:38:57 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-03-17 16:52:33 +0100 |
commit | 23b13bce74626a43b9271a08d037eb0af87273ab (patch) | |
tree | fdaeae8a32df06ea203212f89fd3ac82adb8b04e /framework/inc/threadhelp | |
parent | 5f93d80b4ad5e02c4edd6b2b068af009aacbec70 (diff) |
No need for framework::IRWLock interface
...of which framework::LockHelper is the only implementation
Change-Id: I235bb699ff26b1579803f617990fc4f71fe18b22
Diffstat (limited to 'framework/inc/threadhelp')
-rw-r--r-- | framework/inc/threadhelp/irwlock.h | 71 | ||||
-rw-r--r-- | framework/inc/threadhelp/lockhelper.hxx | 32 | ||||
-rw-r--r-- | framework/inc/threadhelp/readguard.hxx | 12 | ||||
-rw-r--r-- | framework/inc/threadhelp/resetableguard.hxx | 1 | ||||
-rw-r--r-- | framework/inc/threadhelp/writeguard.hxx | 12 |
5 files changed, 26 insertions, 102 deletions
diff --git a/framework/inc/threadhelp/irwlock.h b/framework/inc/threadhelp/irwlock.h deleted file mode 100644 index e8e7165bb9d5..000000000000 --- a/framework/inc/threadhelp/irwlock.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you 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 . - */ - -#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_IRWLOCK_H -#define INCLUDED_FRAMEWORK_INC_THREADHELP_IRWLOCK_H - -namespace framework{ - -/*-************************************************************************************************************ - @descr A guard (specialy a write guard) support different internal working states. - His lock can set for reading or writing/reading! Or he was unlocked by user ... -*//*-*************************************************************************************************************/ -enum ELockMode -{ - E_NOLOCK , - E_READLOCK , - E_WRITELOCK -}; - -/*-************************************************************************************************************ - @descr We implement two guards for using an rw-lock. But if you wish to implement - different rw-locks to you will have problems by using with same guard implementation! - Thats why we define this "pure virtual base class" ... - All rw-locks must support this base interface for working and all guard must use this one too! -*//*-*************************************************************************************************************/ -class IRWLock -{ - - // public methods - - public: - - /*-**************************************************************************************************** - @descr These functions must be supported by a derived class! - acquireReadAccess() -try to register thread as reader - releaseReadAccess() -unregister thread as reader - acquireWriteAccess() -try to register thread as writer - releaseWriteAccess() -unregister thread as writer - downgradeWriteAccess() -make writer to reader - *//*-*****************************************************************************************************/ - virtual void acquireReadAccess () =0; - virtual void releaseReadAccess () =0; - virtual void acquireWriteAccess () =0; - virtual void releaseWriteAccess () =0; - virtual void downgradeWriteAccess () =0; - - protected: - ~IRWLock() {} -}; // class IRWLock - -} // namespace framework - -#endif // INCLUDED_FRAMEWORK_INC_THREADHELP_IRWLOCK_H - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/threadhelp/lockhelper.hxx b/framework/inc/threadhelp/lockhelper.hxx index 55b845c69042..8ff5b3604708 100644 --- a/framework/inc/threadhelp/lockhelper.hxx +++ b/framework/inc/threadhelp/lockhelper.hxx @@ -22,7 +22,6 @@ #include <boost/noncopyable.hpp> #include <framework/imutex.hxx> -#include <threadhelp/irwlock.h> #include <comphelper/solarmutex.hxx> #include <fwidllapi.h> @@ -32,6 +31,17 @@ namespace osl { class Mutex; } namespace framework{ /*-************************************************************************************************************ + @descr A guard (specialy a write guard) support different internal working states. + His lock can set for reading or writing/reading! Or he was unlocked by user ... +*//*-*************************************************************************************************************/ +enum ELockMode +{ + E_NOLOCK , + E_READLOCK , + E_WRITELOCK +}; + +/*-************************************************************************************************************ @short helper to set right lock in right situation @descr This helper support different types of locking: a) no locks - transparent for user! @@ -45,19 +55,13 @@ namespace framework{ An object use an implementation of a fair rw-lock. This increase granularity of t hreadsafe mechanism and should be used for high performance threadsafe code! - @attention We support two interfaces - "IMutex" and "IRWLock". Don't mix using of it! - A guard implementation should use one interface only! - @implements IMutex - @implements IRWLock @base IMutex - IRWLock @devstatus draft *//*-*************************************************************************************************************/ class FWI_DLLPUBLIC LockHelper : public IMutex - , public IRWLock , private boost::noncopyable { @@ -77,15 +81,11 @@ class FWI_DLLPUBLIC LockHelper : public IMutex virtual void acquire(); virtual void release(); - - // interface ::framework::IRWLock - - virtual void acquireReadAccess (); - virtual void releaseReadAccess (); - virtual void acquireWriteAccess (); - virtual void releaseWriteAccess (); - virtual void downgradeWriteAccess(); - + void acquireReadAccess (); + void releaseReadAccess (); + void acquireWriteAccess (); + void releaseWriteAccess (); + void downgradeWriteAccess(); // something else diff --git a/framework/inc/threadhelp/readguard.hxx b/framework/inc/threadhelp/readguard.hxx index a58a6d89c270..e16b99dae510 100644 --- a/framework/inc/threadhelp/readguard.hxx +++ b/framework/inc/threadhelp/readguard.hxx @@ -21,7 +21,7 @@ #define INCLUDED_FRAMEWORK_INC_THREADHELP_READGUARD_HXX #include <boost/noncopyable.hpp> -#include <threadhelp/irwlock.h> +#include <threadhelp/lockhelper.hxx> #include <sal/types.h> @@ -35,9 +35,7 @@ namespace framework{ We never need a own mutex to safe our internal member access - because a guard is used as function-local member only. There exist no multithreaded access to it really ... - @attention a) To prevent us against wrong using, the default ctor, copy ctor and the =operator are maked private! - b) Use interface "IRWLock" of set LockHelper only - because we must support a finer granularity of locking. - Interface "IMutex" should be used by easier guard implementations ... like "ResetableGuard"! + @attention To prevent us against wrong using, the default ctor, copy ctor and the =operator are maked private! @implements - @@ -63,7 +61,7 @@ class ReadGuard : private boost::noncopyable @onerror - *//*-*****************************************************************************************************/ - inline ReadGuard( IRWLock* pLock ) + inline ReadGuard( LockHelper* pLock ) : m_pLock ( pLock ) , m_bLocked ( sal_False ) { @@ -71,7 +69,7 @@ class ReadGuard : private boost::noncopyable } - inline ReadGuard( IRWLock& rLock ) + inline ReadGuard( LockHelper& rLock ) : m_pLock ( &rLock ) , m_bLocked ( sal_False ) { @@ -159,7 +157,7 @@ class ReadGuard : private boost::noncopyable private: - IRWLock* m_pLock ; /// reference to lock-member of protected object + LockHelper* m_pLock ; /// reference to lock-member of protected object sal_Bool m_bLocked ; /// protection against multiple lock calls without unlock! }; // class ReadGuard diff --git a/framework/inc/threadhelp/resetableguard.hxx b/framework/inc/threadhelp/resetableguard.hxx index 5303820c1b29..e1adc4b96804 100644 --- a/framework/inc/threadhelp/resetableguard.hxx +++ b/framework/inc/threadhelp/resetableguard.hxx @@ -37,7 +37,6 @@ namespace framework{ @attention a) To prevent us against wrong using, the default ctor, copy ctor and the =operator are maked private! b) Use interface "IMutex" of set LockHelper only - because we must support an exclusiv locking. - Interface "IRWLock" should be used by special guard implementations ... like "ReadGuard" or "WriteGuard"! @implements - diff --git a/framework/inc/threadhelp/writeguard.hxx b/framework/inc/threadhelp/writeguard.hxx index b25fc7f7b12c..74b56f397e56 100644 --- a/framework/inc/threadhelp/writeguard.hxx +++ b/framework/inc/threadhelp/writeguard.hxx @@ -21,7 +21,7 @@ #define INCLUDED_FRAMEWORK_INC_THREADHELP_WRITEGUARD_HXX #include <boost/noncopyable.hpp> -#include <threadhelp/irwlock.h> +#include <threadhelp/lockhelper.hxx> namespace framework{ @@ -32,9 +32,7 @@ namespace framework{ We never need a own mutex to safe our internal member access - because a guard is used as function-local member only. There exist no multithreaded access to it really ... - @attention a) To prevent us against wrong using, the default ctor, copy ctor and the =operator are maked private! - b) Use interface "IRWLock" of set LockHelper only - because we must support a finer granularity of locking. - Interface "IMutex" should be used by easier guard implementations ... like "ResetableGuard"! + @attention To prevent us against wrong using, the default ctor, copy ctor and the =operator are maked private! @implements - @@ -60,7 +58,7 @@ class WriteGuard : private boost::noncopyable @onerror - *//*-*****************************************************************************************************/ - inline WriteGuard( IRWLock* pLock ) + inline WriteGuard( LockHelper* pLock ) : m_pLock ( pLock ) , m_eMode ( E_NOLOCK ) { @@ -68,7 +66,7 @@ class WriteGuard : private boost::noncopyable } - inline WriteGuard( IRWLock& rLock ) + inline WriteGuard( LockHelper& rLock ) : m_pLock ( &rLock ) , m_eMode ( E_NOLOCK ) { @@ -218,7 +216,7 @@ class WriteGuard : private boost::noncopyable private: - IRWLock* m_pLock ; /// reference to lock-member of protected object + LockHelper* m_pLock ; /// reference to lock-member of protected object ELockMode m_eMode ; /// protection against multiple lock calls without unlock and difference between supported lock modi }; // class WriteGuard |