diff options
author | Matthias Huetsch <mhu@openoffice.org> | 2001-03-13 19:45:39 +0000 |
---|---|---|
committer | Matthias Huetsch <mhu@openoffice.org> | 2001-03-13 19:45:39 +0000 |
commit | d0378cade4e3a2065598f47e288ff4b4a90295a7 (patch) | |
tree | d6afd9554d97efe7938fceb5d7e3fee5aa749541 /store | |
parent | 2744bacc5220c15f8148807afa739bf8a9186c60 (diff) |
Major revision. Removed usage of module 'vos'.
#74475# Fixed 'store_rebuildFile()' circular reference w/ daemon thread.
Diffstat (limited to 'store')
-rw-r--r-- | store/source/storpage.cxx | 116 | ||||
-rw-r--r-- | store/source/storpage.hxx | 70 |
2 files changed, 107 insertions, 79 deletions
diff --git a/store/source/storpage.cxx b/store/source/storpage.cxx index 203a5a669..a8c53025c 100644 --- a/store/source/storpage.cxx +++ b/store/source/storpage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: storpage.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:18:32 $ + * last change: $Author: mhu $ $Date: 2001-03-13 20:45:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -54,12 +54,12 @@ * * All Rights Reserved. * - * Contributor(s): _______________________________________ + * Contributor(s): Matthias Huetsch <matthias.huetsch@sun.com> * * ************************************************************************/ -#define _STORE_STORPAGE_CXX_ "$Revision: 1.1.1.1 $" +#define _STORE_STORPAGE_CXX_ "$Revision: 1.2 $" #ifndef _SAL_TYPES_H_ #include <sal/types.h> @@ -71,20 +71,20 @@ #ifndef _RTL_STRING_H_ #include <rtl/string.h> #endif +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> +#endif -#ifndef _VOS_DIAGNOSE_HXX_ -#include <vos/diagnose.hxx> +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> #endif -#ifndef _VOS_MUTEX_HXX_ -#include <vos/mutex.hxx> +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> #endif #ifndef _STORE_TYPES_H_ #include <store/types.h> #endif -#ifndef _STORE_MACROS_HXX_ -#include <store/macros.hxx> -#endif #ifndef _STORE_OBJECT_HXX_ #include <store/object.hxx> #endif @@ -112,20 +112,14 @@ #include <storpage.hxx> #endif -#ifdef _USE_NAMESPACE using namespace store; -#endif /*======================================================================== * * OStorePageManager implementation. * *======================================================================*/ -VOS_IMPLEMENT_CLASSINFO( - VOS_CLASSNAME (OStorePageManager, store), - VOS_NAMESPACE (OStorePageManager, store), - VOS_NAMESPACE (OStorePageBIOS, store), - 0); +const sal_uInt32 OStorePageManager::m_nTypeId = sal_uInt32(0x62190120); /* * OStorePageManager. @@ -148,8 +142,7 @@ OStorePageManager::OStorePageManager (void) m_pLink[2] = NULL; // Daemon (kflushd :-). - if (OStorePageDaemon::getOrCreate (m_xDaemon)) - m_xDaemon->insert (this); + OStorePageDaemon::getOrCreate (m_xDaemon); } /* @@ -157,9 +150,12 @@ OStorePageManager::OStorePageManager (void) */ OStorePageManager::~OStorePageManager (void) { - NAMESPACE_VOS(OGuard) aGuard (*this); - if (m_xDaemon.isValid()) + osl::MutexGuard aGuard (*this); + if (m_xDaemon.is()) + { m_xDaemon->remove (this); + m_xDaemon.clear(); + } delete m_pCache; delete m_pDirect; @@ -175,6 +171,14 @@ OStorePageManager::~OStorePageManager (void) } /* + * isKindOf. + */ +sal_Bool SAL_CALL OStorePageManager::isKindOf (sal_uInt32 nTypeId) +{ + return (nTypeId == m_nTypeId); +} + +/* * initialize (two-phase construction). * Precond: none. */ @@ -184,7 +188,7 @@ storeError OStorePageManager::initialize ( sal_uInt16 nPageSize) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check arguments. if (!pLockBytes) @@ -211,7 +215,7 @@ storeError OStorePageManager::initialize ( // Obtain page size. eErrCode = base::getPageSize (m_nPageSize); - VOS_POSTCOND( + OSL_POSTCOND( eErrCode == store_E_None, "OStorePageManager::initialize(): getPageSize() failed"); if (eErrCode != store_E_None) @@ -236,6 +240,12 @@ storeError OStorePageManager::initialize ( { m_pNode[1] = new(m_nPageSize) page(m_nPageSize); m_pNode[2] = new(m_nPageSize) page(m_nPageSize); + + if (m_xDaemon.is()) + { + // Request to be flushed. + m_xDaemon->insert (this); + } } // Initialize page cache. @@ -252,7 +262,7 @@ storeError OStorePageManager::initialize ( storeError OStorePageManager::free (OStorePageObject &rPage) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -282,7 +292,7 @@ storeError OStorePageManager::free (OStorePageObject &rPage) storeError OStorePageManager::load (OStorePageObject &rPage) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -329,7 +339,7 @@ storeError OStorePageManager::load (OStorePageObject &rPage) storeError OStorePageManager::save (OStorePageObject &rPage) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -388,7 +398,7 @@ storeError OStorePageManager::save (OStorePageObject &rPage) storeError OStorePageManager::flush (void) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -400,7 +410,7 @@ storeError OStorePageManager::flush (void) // Flush cache. storeError eErrCode = m_pCache->flush (*this, NULL); - VOS_POSTCOND( + OSL_POSTCOND( eErrCode == store_E_None, "OStorePageManager::flush(): cache::flush() failed"); @@ -601,7 +611,7 @@ storeError OStorePageManager::remove ( result = rEntry.compare (rPage.m_pData[i]); } - VOS_POSTCOND( + OSL_POSTCOND( result != entry::COMPARE_LESS, "OStorePageManager::remove(): find failed"); @@ -626,7 +636,7 @@ storeError OStorePageManager::load ( OStoreDirectoryPageObject &rPage) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -678,7 +688,7 @@ storeError OStorePageManager::save ( OStoreDirectoryPageObject &rPage) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -702,7 +712,7 @@ storeError OStorePageManager::save ( { // Compare entry. entry::CompareResult result = e.compare (m_pNode[0]->m_pData[i]); - VOS_POSTCOND( + OSL_POSTCOND( result != entry::COMPARE_LESS, "OStorePageManager::save(): find failed"); @@ -765,7 +775,7 @@ storeError OStorePageManager::attrib ( sal_uInt32 &rAttrib) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -840,7 +850,7 @@ storeError OStorePageManager::link ( const OStorePageKey &rDstKey) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -896,7 +906,7 @@ storeError OStorePageManager::link ( { // Compare entry. entry::CompareResult result = e.compare (m_pNode[0]->m_pData[i]); - VOS_POSTCOND( + OSL_POSTCOND( result != entry::COMPARE_LESS, "OStorePageManager::link(): find failed"); @@ -931,7 +941,7 @@ storeError OStorePageManager::symlink ( const OStorePageKey &rDstKey) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -966,7 +976,7 @@ storeError OStorePageManager::symlink ( { // Compare entry. entry::CompareResult result = e.compare (m_pNode[0]->m_pData[i]); - VOS_POSTCOND( + OSL_POSTCOND( result != entry::COMPARE_LESS, "OStorePageManager::symlink(): find failed"); @@ -1034,7 +1044,7 @@ storeError OStorePageManager::rename ( const rtl_String *pDstName) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -1125,7 +1135,7 @@ storeError OStorePageManager::rename ( { // Compare entry. entry::CompareResult result = e.compare (m_pNode[0]->m_pData[i]); - VOS_POSTCOND( + OSL_POSTCOND( result != entry::COMPARE_LESS, "OStorePageManager::rename(): find failed"); @@ -1185,7 +1195,7 @@ storeError OStorePageManager::rename ( storeError OStorePageManager::remove (const OStorePageKey &rKey) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -1297,7 +1307,7 @@ storeError OStorePageManager::iterate ( sal_uInt32 &rAttrib) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check precond. if (!self::isValid()) @@ -1322,7 +1332,7 @@ storeError OStorePageManager::iterate ( // Compare entry. entry::CompareResult result = e.compare (m_pNode[0]->m_pData[i]); - VOS_POSTCOND( + OSL_POSTCOND( result != entry::COMPARE_LESS, "OStorePageManager::iterate(): find failed"); @@ -1353,8 +1363,8 @@ struct RebuildContext { /** Representation. */ - NAMESPACE_VOS(ORef)<OStorePageBIOS> m_xBIOS; - OStorePageBIOS::ScanContext m_aCtx; + rtl::Reference<OStorePageBIOS> m_xBIOS; + OStorePageBIOS::ScanContext m_aCtx; /** Construction. */ @@ -1408,7 +1418,7 @@ storeError OStorePageManager::rebuild ( ILockBytes *pSrcLB, ILockBytes *pDstLB) { // Acquire exclusive access. - NAMESPACE_VOS(OGuard) aGuard(*this); + osl::MutexGuard aGuard(*this); // Check arguments. storeError eErrCode = store_E_InvalidParameter; @@ -1427,6 +1437,9 @@ storeError OStorePageManager::rebuild ( if (eErrCode != store_E_None) return eErrCode; + // Prevent flush() attempt from daemon during exclusive access. + m_xDaemon.clear(); + // Initialize as 'Destination' with 'Source' page size. eErrCode = self::initialize (pDstLB, store_AccessCreate, nPageSize); if (eErrCode != store_E_None) @@ -1491,8 +1504,8 @@ storeError OStorePageManager::rebuild ( m_pData->m_aDescr.m_nSize = m_nPageSize; // Read 'Source' data page. - OStorePageBIOS &rBIOS = *(aCtx.m_xBIOS); - NAMESPACE_VOS(IMutex) &rMutex = rBIOS; + OStorePageBIOS &rBIOS = *(aCtx.m_xBIOS); + osl::Mutex &rMutex = rBIOS; eErrCode = aSrcPage.get ( i, m_pLink[0], m_pLink[1], m_pLink[2], @@ -1512,6 +1525,9 @@ storeError OStorePageManager::rebuild ( } } + // Save directory scan results. + flush(); + // Scan 'Source' BTree nodes. page *pNode = new(m_nPageSize) page(m_nPageSize); node aNode (*pNode); @@ -1552,6 +1568,9 @@ storeError OStorePageManager::rebuild ( } } + // Save BTree node scan results. + flush(); + // Cleanup. delete pDirect; delete pNode; @@ -1559,4 +1578,3 @@ storeError OStorePageManager::rebuild ( // Done. return store_E_None; } - diff --git a/store/source/storpage.hxx b/store/source/storpage.hxx index ef9dd172b..0ff4c4f51 100644 --- a/store/source/storpage.hxx +++ b/store/source/storpage.hxx @@ -2,9 +2,9 @@ * * $RCSfile: storpage.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:18:32 $ + * last change: $Author: mhu $ $Date: 2001-03-13 20:45:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -54,33 +54,24 @@ * * All Rights Reserved. * - * Contributor(s): _______________________________________ + * Contributor(s): Matthias Huetsch <matthias.huetsch@sun.com> * * ************************************************************************/ #ifndef _STORE_STORPAGE_HXX_ -#define _STORE_STORPAGE_HXX_ "$Revision: 1.1.1.1 $" +#define _STORE_STORPAGE_HXX_ "$Revision: 1.2 $" #ifndef _SAL_TYPES_H_ #include <sal/types.h> #endif -#ifndef _VOS_MACROS_HXX_ -#include <vos/macros.hxx> -#endif -#ifndef _VOS_OBJECT_HXX_ -#include <vos/object.hxx> -#endif -#ifndef _VOS_REF_HXX_ -#include <vos/ref.hxx> +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> #endif -#ifndef _STORE_TYPES_H_ -#include <store/types.h> -#endif -#ifndef _STORE_MACROS_HXX_ -#include <store/macros.hxx> +#ifndef _STORE_OBJECT_HXX_ +#include <store/object.hxx> #endif #ifndef _STORE_LOCKBYTE_HXX_ #include <store/lockbyte.hxx> @@ -93,9 +84,8 @@ #include <stordmon.hxx> #endif -#ifdef _USE_NAMESPACE -namespace store { -#endif +namespace store +{ struct OStoreBTreeEntry; struct OStoreBTreeNodeData; @@ -112,10 +102,8 @@ class OStorePageCache; * OStorePageManager interface. * *======================================================================*/ -class OStorePageManager : public NAMESPACE_STORE(OStorePageBIOS) +class OStorePageManager : public store::OStorePageBIOS { - VOS_DECLARE_CLASSINFO (VOS_NAMESPACE (OStorePageManager, store)); - public: /** Construction. */ @@ -206,8 +194,12 @@ public: ILockBytes *pSrcLB, ILockBytes *pDstLB); + /** IStoreHandle. + */ + virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId); + protected: - /** Destruction (OReference). + /** Destruction. */ virtual ~OStorePageManager (void); @@ -225,11 +217,19 @@ private: typedef OStoreIndirectionPageData indirect; typedef OStoreDataPageData data; + /** IStoreHandle TypeId. + */ + static const sal_uInt32 m_nTypeId; + + /** IStoreHandle query() template function specialization. + */ + friend inline OStorePageManager* + SAL_CALL query (IStoreHandle *pHandle, OStorePageManager*); + /** Representation. */ - typedef NAMESPACE_VOS(ORef)<OStorePageDaemon> OStorePageDaemonRef; - OStorePageDaemonRef m_xDaemon; - OStorePageCache *m_pCache; + rtl::Reference<OStorePageDaemon> m_xDaemon; + OStorePageCache *m_pCache; page *m_pNode[3]; inode *m_pDirect; @@ -263,14 +263,24 @@ inline sal_Bool OStorePageManager::isValid (void) const return (base::isValid() && (m_nPageSize > 0)); } +inline OStorePageManager* +SAL_CALL query (IStoreHandle *pHandle, OStorePageManager*) +{ + if (pHandle && pHandle->isKindOf (OStorePageManager::m_nTypeId)) + { + // Handle is kind of OStorePageManager. + return static_cast<OStorePageManager*>(pHandle); + } + return 0; +} + /*======================================================================== * * The End. * *======================================================================*/ -#ifdef _USE_NAMESPACE -} -#endif + +} // namespace store #endif /* !_STORE_STORPAGE_HXX_ */ |