Kaydet (Commit) bc30f938 authored tarafından Noel Grandin's avatar Noel Grandin

use SimpleReferenceObject in stoc module

to replace hand-rolled version

Change-Id: I30635aec81313e4e0d1b67b30c8992fd63bb1f67
üst 0ae79a13
...@@ -18,6 +18,7 @@ $(eval $(call gb_Library_add_defs,store,\ ...@@ -18,6 +18,7 @@ $(eval $(call gb_Library_add_defs,store,\
$(eval $(call gb_Library_use_libraries,store,\ $(eval $(call gb_Library_use_libraries,store,\
sal \ sal \
salhelper \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
)) ))
......
...@@ -308,11 +308,6 @@ public: ...@@ -308,11 +308,6 @@ public:
*/ */
explicit FileLockBytes (FileHandle & rFile); explicit FileLockBytes (FileHandle & rFile);
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
protected: protected:
/** Destruction. /** Destruction.
*/ */
...@@ -331,16 +326,6 @@ FileLockBytes::~FileLockBytes() ...@@ -331,16 +326,6 @@ FileLockBytes::~FileLockBytes()
FileHandle::closeFile (m_hFile); FileHandle::closeFile (m_hFile);
} }
oslInterlockedCount SAL_CALL FileLockBytes::acquire()
{
return OStoreObject::acquire();
}
oslInterlockedCount SAL_CALL FileLockBytes::release()
{
return OStoreObject::release();
}
storeError FileLockBytes::initSize_Impl (sal_uInt32 & rnSize) storeError FileLockBytes::initSize_Impl (sal_uInt32 & rnSize)
{ {
/* osl_getFileSize() uses slow 'fstat(h, &size)', /* osl_getFileSize() uses slow 'fstat(h, &size)',
...@@ -548,11 +533,6 @@ public: ...@@ -548,11 +533,6 @@ public:
*/ */
explicit MappedLockBytes (FileMapping & rMapping); explicit MappedLockBytes (FileMapping & rMapping);
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
protected: protected:
/* Destruction. /* Destruction.
*/ */
...@@ -571,16 +551,6 @@ MappedLockBytes::~MappedLockBytes() ...@@ -571,16 +551,6 @@ MappedLockBytes::~MappedLockBytes()
FileMapping::unmapFile (m_hFile, m_pData, m_nSize); FileMapping::unmapFile (m_hFile, m_pData, m_nSize);
} }
oslInterlockedCount SAL_CALL MappedLockBytes::acquire()
{
return OStoreObject::acquire();
}
oslInterlockedCount SAL_CALL MappedLockBytes::release()
{
return OStoreObject::release();
}
void MappedLockBytes::allocate_Impl (void ** ppPage, sal_uInt16 * pnSize) void MappedLockBytes::allocate_Impl (void ** ppPage, sal_uInt16 * pnSize)
{ {
OSL_PRECOND((ppPage != 0) && (pnSize != 0), "contract violation"); OSL_PRECOND((ppPage != 0) && (pnSize != 0), "contract violation");
...@@ -696,11 +666,6 @@ public: ...@@ -696,11 +666,6 @@ public:
*/ */
MemoryLockBytes(); MemoryLockBytes();
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
protected: protected:
/** Destruction. /** Destruction.
*/ */
...@@ -718,16 +683,6 @@ MemoryLockBytes::~MemoryLockBytes() ...@@ -718,16 +683,6 @@ MemoryLockBytes::~MemoryLockBytes()
rtl_freeMemory (m_pData); rtl_freeMemory (m_pData);
} }
oslInterlockedCount SAL_CALL MemoryLockBytes::acquire (void)
{
return OStoreObject::acquire();
}
oslInterlockedCount SAL_CALL MemoryLockBytes::release (void)
{
return OStoreObject::release();
}
storeError MemoryLockBytes::initialize_Impl (rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize) storeError MemoryLockBytes::initialize_Impl (rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize)
{ {
storeError result = PageData::Allocator::createInstance (rxAllocator, nPageSize); storeError result = PageData::Allocator::createInstance (rxAllocator, nPageSize);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "rtl/ref.hxx" #include "rtl/ref.hxx"
#include "rtl/ustring.h" #include "rtl/ustring.h"
#include "salhelper/simplereferenceobject.hxx"
#include "store/types.h" #include "store/types.h"
#include "storbase.hxx" #include "storbase.hxx"
...@@ -36,7 +37,7 @@ namespace store ...@@ -36,7 +37,7 @@ namespace store
* ILockBytes interface. * ILockBytes interface.
* *
*======================================================================*/ *======================================================================*/
class ILockBytes : public rtl::IReference class ILockBytes : public virtual salhelper::SimpleReferenceObject
{ {
public: public:
/** /**
...@@ -103,7 +104,7 @@ public: ...@@ -103,7 +104,7 @@ public:
storeError flush(); storeError flush();
protected: protected:
~ILockBytes() {} virtual ~ILockBytes() {}
private: private:
/** Implementation (abstract). /** Implementation (abstract).
......
...@@ -35,38 +35,6 @@ namespace store ...@@ -35,38 +35,6 @@ namespace store
*======================================================================*/ *======================================================================*/
const sal_uInt32 OStoreObject::m_nTypeId = sal_uInt32(0x58190322); const sal_uInt32 OStoreObject::m_nTypeId = sal_uInt32(0x58190322);
/*
* OStoreObject.
*/
OStoreObject::OStoreObject (void)
: m_nRefCount (0)
{
}
/*
* ~OStoreObject.
*/
OStoreObject::~OStoreObject (void)
{
OSL_ASSERT(m_nRefCount == 0);
}
/*
* operator new.
*/
void* OStoreObject::operator new (size_t n)
{
return rtl_allocateMemory (n);
}
/*
* operator delete.
*/
void OStoreObject::operator delete (void *p)
{
rtl_freeMemory (p);
}
/* /*
* isKindOf. * isKindOf.
*/ */
...@@ -75,29 +43,6 @@ bool OStoreObject::isKindOf (sal_uInt32 nTypeId) ...@@ -75,29 +43,6 @@ bool OStoreObject::isKindOf (sal_uInt32 nTypeId)
return (nTypeId == m_nTypeId); return (nTypeId == m_nTypeId);
} }
/*
* acquire.
*/
oslInterlockedCount SAL_CALL OStoreObject::acquire (void)
{
oslInterlockedCount result = osl_atomic_increment (&m_nRefCount);
return (result);
}
/*
* release.
*/
oslInterlockedCount SAL_CALL OStoreObject::release (void)
{
oslInterlockedCount result = osl_atomic_decrement (&m_nRefCount);
if (result == 0)
{
// Last reference released.
delete this;
}
return (result);
}
} // namespace store } // namespace store
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -21,10 +21,9 @@ ...@@ -21,10 +21,9 @@
#define INCLUDED_STORE_SOURCE_OBJECT_HXX #define INCLUDED_STORE_SOURCE_OBJECT_HXX
#include "sal/types.h" #include "sal/types.h"
#include "rtl/ref.hxx" #include "rtl/ref.hxx"
#include "osl/interlck.h" #include "osl/interlck.h"
#include "salhelper/simplereferenceobject.hxx"
namespace store namespace store
{ {
...@@ -34,7 +33,7 @@ namespace store ...@@ -34,7 +33,7 @@ namespace store
* IStoreHandle interface. * IStoreHandle interface.
* *
*======================================================================*/ *======================================================================*/
class IStoreHandle : public rtl::IReference class IStoreHandle : public virtual salhelper::SimpleReferenceObject
{ {
public: public:
/** Replaces dynamic_cast type checking. /** Replaces dynamic_cast type checking.
...@@ -42,7 +41,7 @@ public: ...@@ -42,7 +41,7 @@ public:
virtual bool isKindOf (sal_uInt32 nTypeId) = 0; virtual bool isKindOf (sal_uInt32 nTypeId) = 0;
protected: protected:
~IStoreHandle() {} virtual ~IStoreHandle() {}
}; };
/** Template helper function as dynamic_cast replacement. /** Template helper function as dynamic_cast replacement.
...@@ -66,26 +65,16 @@ class OStoreObject : public store::IStoreHandle ...@@ -66,26 +65,16 @@ class OStoreObject : public store::IStoreHandle
public: public:
/** Construction. /** Construction.
*/ */
OStoreObject (void); OStoreObject() {}
/** Allocation.
*/
static void* operator new (size_t n);
static void operator delete (void *p);
/** IStoreHandle. /** IStoreHandle.
*/ */
virtual bool isKindOf (sal_uInt32 nTypeId) SAL_OVERRIDE; virtual bool isKindOf (sal_uInt32 nTypeId) SAL_OVERRIDE;
/** IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire (void) SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release (void) SAL_OVERRIDE;
protected: protected:
/** Destruction. /** Destruction.
*/ */
virtual ~OStoreObject (void); virtual ~OStoreObject() {}
private: private:
/** The IStoreHandle TypeId. /** The IStoreHandle TypeId.
......
...@@ -84,17 +84,6 @@ public: ...@@ -84,17 +84,6 @@ public:
storeError initialize (sal_uInt16 nPageSize); storeError initialize (sal_uInt16 nPageSize);
/** Delegate multiple inherited rtl::IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE
{
return OStoreObject::acquire();
}
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE
{
return OStoreObject::release();
}
protected: protected:
/** Destruction. /** Destruction.
*/ */
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define INCLUDED_STORE_SOURCE_STORBASE_HXX #define INCLUDED_STORE_SOURCE_STORBASE_HXX
#include "sal/config.h" #include "sal/config.h"
#include "salhelper/simplereferenceobject.hxx"
#include "boost/static_assert.hpp" #include "boost/static_assert.hpp"
#include "sal/types.h" #include "sal/types.h"
...@@ -454,7 +455,7 @@ struct PageData ...@@ -454,7 +455,7 @@ struct PageData
/** Allocation. /** Allocation.
*/ */
class Allocator_Impl; class Allocator_Impl;
class Allocator : public rtl::IReference class Allocator : public virtual salhelper::SimpleReferenceObject
{ {
public: public:
template< class T > T * construct() template< class T > T * construct()
...@@ -483,7 +484,7 @@ struct PageData ...@@ -483,7 +484,7 @@ struct PageData
rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize); rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize);
protected: protected:
~Allocator() {} virtual ~Allocator() {}
private: private:
/** Implementation (abstract). /** Implementation (abstract).
......
...@@ -274,10 +274,6 @@ public: ...@@ -274,10 +274,6 @@ public:
// Construction // Construction
explicit PageCache_Impl (sal_uInt16 nPageSize); explicit PageCache_Impl (sal_uInt16 nPageSize);
// Delegate multiple inherited IReference
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
protected: protected:
// Destruction // Destruction
virtual ~PageCache_Impl (void); virtual ~PageCache_Impl (void);
...@@ -330,16 +326,6 @@ PageCache_Impl::~PageCache_Impl() ...@@ -330,16 +326,6 @@ PageCache_Impl::~PageCache_Impl()
OSL_TRACE("Hits: %zu, Misses: %zu", m_nHit, m_nMissed); OSL_TRACE("Hits: %zu, Misses: %zu", m_nHit, m_nMissed);
} }
oslInterlockedCount PageCache_Impl::acquire()
{
return OStoreObject::acquire();
}
oslInterlockedCount PageCache_Impl::release()
{
return OStoreObject::release();
}
void PageCache_Impl::rescale_Impl (sal_Size new_size) void PageCache_Impl::rescale_Impl (sal_Size new_size)
{ {
sal_Size new_bytes = new_size * sizeof(Entry*); sal_Size new_bytes = new_size * sizeof(Entry*);
......
...@@ -35,7 +35,7 @@ namespace store ...@@ -35,7 +35,7 @@ namespace store
* *
*======================================================================*/ *======================================================================*/
class PageCache : public rtl::IReference class PageCache : public virtual salhelper::SimpleReferenceObject
{ {
public: public:
/** load. /** load.
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
sal_uInt32 nOffset); sal_uInt32 nOffset);
protected: protected:
~PageCache() {} virtual ~PageCache() {}
private: private:
/** Implementation (abstract). /** Implementation (abstract).
......
...@@ -176,7 +176,7 @@ struct PageData ...@@ -176,7 +176,7 @@ struct PageData
/** Allocation. /** Allocation.
*/ */
class Allocator : public rtl::IReference class Allocator : public salhelper::SimpleReferenceObject
{ {
public: public:
template< class T > T * construct() template< class T > T * construct()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment