No need for framework::IRWLock interface
...of which framework::LockHelper is the only implementation Change-Id: I235bb699ff26b1579803f617990fc4f71fe18b22
This commit is contained in:
parent
5f93d80b4a
commit
23b13bce74
@ -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: */
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <framework/imutex.hxx>
|
||||
#include <threadhelp/irwlock.h>
|
||||
|
||||
#include <comphelper/solarmutex.hxx>
|
||||
#include <fwidllapi.h>
|
||||
@ -31,6 +30,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:
|
||||
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 -
|
||||
|
||||
|
@ -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
|
||||
|
@ -130,7 +130,6 @@ void LockHelper::release()
|
||||
}
|
||||
|
||||
/*-************************************************************************************************************
|
||||
@interface IRWLock
|
||||
@short set lock for reading
|
||||
@descr A guard should call this method to acquire read access on your member.
|
||||
Writing isn't allowed then - but nobody could check it for you!
|
||||
@ -151,7 +150,6 @@ void LockHelper::acquireReadAccess()
|
||||
}
|
||||
|
||||
/*-************************************************************************************************************
|
||||
@interface IRWLock
|
||||
@short reset lock for reading
|
||||
@descr A guard should call this method to release read access on your member.
|
||||
|
||||
@ -171,7 +169,6 @@ void LockHelper::releaseReadAccess()
|
||||
}
|
||||
|
||||
/*-************************************************************************************************************
|
||||
@interface IRWLock
|
||||
@short set lock for writing
|
||||
@descr A guard should call this method to acquire write access on your member.
|
||||
Reading is allowed too - of course.
|
||||
@ -193,7 +190,6 @@ void LockHelper::acquireWriteAccess()
|
||||
}
|
||||
|
||||
/*-************************************************************************************************************
|
||||
@interface IRWLock
|
||||
@short reset lock for writing
|
||||
@descr A guard should call this method to release write access on your member.
|
||||
|
||||
@ -213,7 +209,6 @@ void LockHelper::releaseWriteAccess()
|
||||
}
|
||||
|
||||
/*-************************************************************************************************************
|
||||
@interface IRWLock
|
||||
@short downgrade a write access to a read access
|
||||
@descr A guard should call this method to change a write to a read access.
|
||||
New readers can work too - new writer are blocked!
|
||||
|
Loading…
x
Reference in New Issue
Block a user