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,\
$(eval $(call gb_Library_use_libraries,store,\
sal \
salhelper \
$(gb_UWINAPI) \
))
......
......@@ -308,11 +308,6 @@ public:
*/
explicit FileLockBytes (FileHandle & rFile);
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
protected:
/** Destruction.
*/
......@@ -331,16 +326,6 @@ FileLockBytes::~FileLockBytes()
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)
{
/* osl_getFileSize() uses slow 'fstat(h, &size)',
......@@ -548,11 +533,6 @@ public:
*/
explicit MappedLockBytes (FileMapping & rMapping);
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
protected:
/* Destruction.
*/
......@@ -571,16 +551,6 @@ MappedLockBytes::~MappedLockBytes()
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)
{
OSL_PRECOND((ppPage != 0) && (pnSize != 0), "contract violation");
......@@ -696,11 +666,6 @@ public:
*/
MemoryLockBytes();
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
protected:
/** Destruction.
*/
......@@ -718,16 +683,6 @@ MemoryLockBytes::~MemoryLockBytes()
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 result = PageData::Allocator::createInstance (rxAllocator, nPageSize);
......
......@@ -24,6 +24,7 @@
#include "rtl/ref.hxx"
#include "rtl/ustring.h"
#include "salhelper/simplereferenceobject.hxx"
#include "store/types.h"
#include "storbase.hxx"
......@@ -36,7 +37,7 @@ namespace store
* ILockBytes interface.
*
*======================================================================*/
class ILockBytes : public rtl::IReference
class ILockBytes : public virtual salhelper::SimpleReferenceObject
{
public:
/**
......@@ -103,7 +104,7 @@ public:
storeError flush();
protected:
~ILockBytes() {}
virtual ~ILockBytes() {}
private:
/** Implementation (abstract).
......
......@@ -35,38 +35,6 @@ namespace store
*======================================================================*/
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.
*/
......@@ -75,29 +43,6 @@ bool OStoreObject::isKindOf (sal_uInt32 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
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -21,10 +21,9 @@
#define INCLUDED_STORE_SOURCE_OBJECT_HXX
#include "sal/types.h"
#include "rtl/ref.hxx"
#include "osl/interlck.h"
#include "salhelper/simplereferenceobject.hxx"
namespace store
{
......@@ -34,7 +33,7 @@ namespace store
* IStoreHandle interface.
*
*======================================================================*/
class IStoreHandle : public rtl::IReference
class IStoreHandle : public virtual salhelper::SimpleReferenceObject
{
public:
/** Replaces dynamic_cast type checking.
......@@ -42,7 +41,7 @@ public:
virtual bool isKindOf (sal_uInt32 nTypeId) = 0;
protected:
~IStoreHandle() {}
virtual ~IStoreHandle() {}
};
/** Template helper function as dynamic_cast replacement.
......@@ -66,26 +65,16 @@ class OStoreObject : public store::IStoreHandle
public:
/** Construction.
*/
OStoreObject (void);
/** Allocation.
*/
static void* operator new (size_t n);
static void operator delete (void *p);
OStoreObject() {}
/** IStoreHandle.
*/
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:
/** Destruction.
*/
virtual ~OStoreObject (void);
virtual ~OStoreObject() {}
private:
/** The IStoreHandle TypeId.
......
......@@ -84,17 +84,6 @@ public:
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:
/** Destruction.
*/
......
......@@ -21,6 +21,7 @@
#define INCLUDED_STORE_SOURCE_STORBASE_HXX
#include "sal/config.h"
#include "salhelper/simplereferenceobject.hxx"
#include "boost/static_assert.hpp"
#include "sal/types.h"
......@@ -454,7 +455,7 @@ struct PageData
/** Allocation.
*/
class Allocator_Impl;
class Allocator : public rtl::IReference
class Allocator : public virtual salhelper::SimpleReferenceObject
{
public:
template< class T > T * construct()
......@@ -483,7 +484,7 @@ struct PageData
rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize);
protected:
~Allocator() {}
virtual ~Allocator() {}
private:
/** Implementation (abstract).
......
......@@ -274,10 +274,6 @@ public:
// Construction
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:
// Destruction
virtual ~PageCache_Impl (void);
......@@ -330,16 +326,6 @@ PageCache_Impl::~PageCache_Impl()
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)
{
sal_Size new_bytes = new_size * sizeof(Entry*);
......
......@@ -35,7 +35,7 @@ namespace store
*
*======================================================================*/
class PageCache : public rtl::IReference
class PageCache : public virtual salhelper::SimpleReferenceObject
{
public:
/** load.
......@@ -62,7 +62,7 @@ public:
sal_uInt32 nOffset);
protected:
~PageCache() {}
virtual ~PageCache() {}
private:
/** Implementation (abstract).
......
......@@ -176,7 +176,7 @@ struct PageData
/** Allocation.
*/
class Allocator : public rtl::IReference
class Allocator : public salhelper::SimpleReferenceObject
{
public:
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