Rename BBlockBufferCache and friends to *Pool*
Also move BBlockBufferPoolNoLock into BHPKG namespace with the other classes. Not sure why it wasn't there before.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
#include <../os/package/BlockBufferCacheNoLock.h>
|
||||
@@ -1 +0,0 @@
|
||||
#include <../os/package/hpkg/BlockBufferCache.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <../os/package/hpkg/BlockBufferPool.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <../os/package/hpkg/BlockBufferPoolNoLock.h>
|
||||
@@ -1 +0,0 @@
|
||||
#include <../os/package/hpkg/BufferCache.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <../os/package/hpkg/BufferPool.h>
|
||||
@@ -1 +0,0 @@
|
||||
#include <../private/package/hpkg/BlockBufferCacheImpl.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <../private/package/hpkg/BlockBufferPoolImpl.h>
|
||||
@@ -1 +0,0 @@
|
||||
#include <../private/package/hpkg/CachedBuffer.h>
|
||||
@@ -0,0 +1 @@
|
||||
#include <../private/package/hpkg/PoolBuffer.h>
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009,2011, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__BLOCK_BUFFER_CACHE_NO_LOCK_H
|
||||
#define _PACKAGE__BLOCK_BUFFER_CACHE_NO_LOCK_H
|
||||
|
||||
|
||||
#include <package/hpkg/BlockBufferCache.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
class BBlockBufferCacheNoLock : public BHPKG::BBlockBufferCache {
|
||||
public:
|
||||
BBlockBufferCacheNoLock(size_t blockSize,
|
||||
uint32 maxCachedBlocks);
|
||||
virtual ~BBlockBufferCacheNoLock();
|
||||
|
||||
virtual bool Lock();
|
||||
virtual void Unlock();
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__BLOCK_BUFFER_CACHE_NO_LOCK_H
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009,2011, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__HPKG__BLOCK_BUFFER_CACHE_H_
|
||||
#define _PACKAGE__HPKG__BLOCK_BUFFER_CACHE_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <package/hpkg/BufferCache.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
class BlockBufferCacheImpl;
|
||||
}
|
||||
using BPrivate::BlockBufferCacheImpl;
|
||||
|
||||
|
||||
class BBlockBufferCache : public BBufferCache, public BBufferCacheLockable {
|
||||
public:
|
||||
BBlockBufferCache(size_t blockSize,
|
||||
uint32 maxCachedBlocks);
|
||||
virtual ~BBlockBufferCache();
|
||||
|
||||
virtual status_t Init();
|
||||
|
||||
virtual CachedBuffer* GetBuffer(size_t size,
|
||||
CachedBuffer** owner = NULL,
|
||||
bool* _newBuffer = NULL);
|
||||
virtual void PutBufferAndCache(CachedBuffer** owner);
|
||||
virtual void PutBuffer(CachedBuffer** owner);
|
||||
|
||||
private:
|
||||
BlockBufferCacheImpl* fImpl;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BHPKG
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__HPKG__BLOCK_BUFFER_CACHE_H_
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2009,2011, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__HPKG__BLOCK_BUFFER_POOL_H_
|
||||
#define _PACKAGE__HPKG__BLOCK_BUFFER_POOL_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <package/hpkg/BufferPool.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
class BlockBufferPoolImpl;
|
||||
}
|
||||
using BPrivate::BlockBufferPoolImpl;
|
||||
|
||||
|
||||
class BBlockBufferPool : public BBufferPool, public BBufferPoolLockable {
|
||||
public:
|
||||
BBlockBufferPool(size_t blockSize,
|
||||
uint32 maxCachedBlocks);
|
||||
virtual ~BBlockBufferPool();
|
||||
|
||||
virtual status_t Init();
|
||||
|
||||
virtual PoolBuffer* GetBuffer(size_t size,
|
||||
PoolBuffer** owner = NULL,
|
||||
bool* _newBuffer = NULL);
|
||||
virtual void PutBufferAndCache(PoolBuffer** owner);
|
||||
virtual void PutBuffer(PoolBuffer** owner);
|
||||
|
||||
private:
|
||||
BlockBufferPoolImpl* fImpl;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BHPKG
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__HPKG__BLOCK_BUFFER_POOL_H_
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2009,2011, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__BLOCK_BUFFER_POOL_NO_LOCK_H
|
||||
#define _PACKAGE__BLOCK_BUFFER_POOL_NO_LOCK_H
|
||||
|
||||
|
||||
#include <package/hpkg/BlockBufferPool.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
class BBlockBufferPoolNoLock : public BHPKG::BBlockBufferPool {
|
||||
public:
|
||||
BBlockBufferPoolNoLock(size_t blockSize,
|
||||
uint32 maxCachedBlocks);
|
||||
virtual ~BBlockBufferPoolNoLock();
|
||||
|
||||
virtual bool Lock();
|
||||
virtual void Unlock();
|
||||
};
|
||||
|
||||
|
||||
} // namespace BHPKG
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__BLOCK_BUFFER_POOL_NO_LOCK_H
|
||||
@@ -2,8 +2,8 @@
|
||||
* Copyright 2009,2011, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__HPKG__BUFFER_CACHE_H_
|
||||
#define _PACKAGE__HPKG__BUFFER_CACHE_H_
|
||||
#ifndef _PACKAGE__HPKG__BUFFER_POOL_H_
|
||||
#define _PACKAGE__HPKG__BUFFER_POOL_H_
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -15,31 +15,31 @@ namespace BHPKG {
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
class CachedBuffer;
|
||||
class PoolBuffer;
|
||||
}
|
||||
using BPrivate::CachedBuffer;
|
||||
using BPrivate::PoolBuffer;
|
||||
|
||||
|
||||
class BBufferCache {
|
||||
class BBufferPool {
|
||||
public:
|
||||
virtual ~BBufferCache();
|
||||
virtual ~BBufferPool();
|
||||
|
||||
virtual CachedBuffer* GetBuffer(size_t size,
|
||||
CachedBuffer** owner = NULL,
|
||||
virtual PoolBuffer* GetBuffer(size_t size,
|
||||
PoolBuffer** owner = NULL,
|
||||
bool* _newBuffer = NULL) = 0;
|
||||
virtual void PutBufferAndCache(CachedBuffer** owner) = 0;
|
||||
virtual void PutBufferAndCache(PoolBuffer** owner) = 0;
|
||||
// caller is buffer owner and wants the
|
||||
// buffer cached, if possible
|
||||
virtual void PutBuffer(CachedBuffer** owner) = 0;
|
||||
virtual void PutBuffer(PoolBuffer** owner) = 0;
|
||||
// puts the buffer for good, owner might
|
||||
// have called PutBufferAndCache() before
|
||||
// and might not own a buffer anymore
|
||||
};
|
||||
|
||||
|
||||
class BBufferCacheLockable {
|
||||
class BBufferPoolLockable {
|
||||
public:
|
||||
virtual ~BBufferCacheLockable();
|
||||
virtual ~BBufferPoolLockable();
|
||||
|
||||
virtual bool Lock() = 0;
|
||||
virtual void Unlock() = 0;
|
||||
@@ -51,4 +51,4 @@ public:
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__HPKG__BUFFER_CACHE_H_
|
||||
#endif // _PACKAGE__HPKG__BUFFER_POOL_H_
|
||||
@@ -14,21 +14,21 @@ namespace BPackageKit {
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
class BBufferCache;
|
||||
class BBufferPool;
|
||||
class BPackageData;
|
||||
|
||||
|
||||
class BPackageDataReaderFactory {
|
||||
public:
|
||||
BPackageDataReaderFactory(
|
||||
BBufferCache* bufferCache);
|
||||
BBufferPool* bufferPool);
|
||||
|
||||
status_t CreatePackageDataReader(BDataReader* dataReader,
|
||||
const BPackageData& data,
|
||||
BAbstractBufferedDataReader*& _reader);
|
||||
|
||||
private:
|
||||
BBufferCache* fBufferCache;
|
||||
BBufferPool* fBufferPool;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace BPackageKit {
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
class BBufferCache;
|
||||
class BBufferPool;
|
||||
|
||||
|
||||
namespace V1 {
|
||||
@@ -26,14 +26,14 @@ class BPackageData;
|
||||
class BPackageDataReaderFactory {
|
||||
public:
|
||||
BPackageDataReaderFactory(
|
||||
BBufferCache* bufferCache);
|
||||
BBufferPool* bufferPool);
|
||||
|
||||
status_t CreatePackageDataReader(BDataReader* dataReader,
|
||||
const BPackageData& data,
|
||||
BAbstractBufferedDataReader*& _reader);
|
||||
|
||||
private:
|
||||
BBufferCache* fBufferCache;
|
||||
BBufferPool* fBufferPool;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_CACHE_H_
|
||||
#define _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_CACHE_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <util/DoublyLinkedList.h>
|
||||
|
||||
#include <package/hpkg/BufferCache.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
namespace BHPKG {
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class CachedBuffer;
|
||||
|
||||
|
||||
class BlockBufferCacheImpl : public BBufferCache {
|
||||
public:
|
||||
BlockBufferCacheImpl(size_t blockSize,
|
||||
uint32 maxCachedBlocks,
|
||||
BBufferCacheLockable* lockable);
|
||||
~BlockBufferCacheImpl();
|
||||
|
||||
status_t Init();
|
||||
|
||||
CachedBuffer* GetBuffer(size_t size,
|
||||
CachedBuffer** owner = NULL,
|
||||
bool* _newBuffer = NULL);
|
||||
void PutBufferAndCache(CachedBuffer** owner);
|
||||
void PutBuffer(CachedBuffer** owner);
|
||||
|
||||
private:
|
||||
typedef DoublyLinkedList<CachedBuffer> BufferList;
|
||||
|
||||
private:
|
||||
CachedBuffer* _AllocateBuffer(size_t size,
|
||||
CachedBuffer** owner, bool* _newBuffer);
|
||||
// object must not be locked
|
||||
|
||||
private:
|
||||
size_t fBlockSize;
|
||||
uint32 fMaxCachedBlocks;
|
||||
uint32 fAllocatedBlocks;
|
||||
BufferList fUnusedBuffers;
|
||||
BufferList fCachedBuffers;
|
||||
BBufferCacheLockable* fLockable;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
} // namespace BHPKG
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_CACHE_H_
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_POOL_H_
|
||||
#define _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_POOL_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <util/DoublyLinkedList.h>
|
||||
|
||||
#include <package/hpkg/BufferPool.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
namespace BHPKG {
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class PoolBuffer;
|
||||
|
||||
|
||||
class BlockBufferPoolImpl : public BBufferPool {
|
||||
public:
|
||||
BlockBufferPoolImpl(size_t blockSize,
|
||||
uint32 maxCachedBlocks,
|
||||
BBufferPoolLockable* lockable);
|
||||
~BlockBufferPoolImpl();
|
||||
|
||||
status_t Init();
|
||||
|
||||
PoolBuffer* GetBuffer(size_t size,
|
||||
PoolBuffer** owner = NULL,
|
||||
bool* _newBuffer = NULL);
|
||||
void PutBufferAndCache(PoolBuffer** owner);
|
||||
void PutBuffer(PoolBuffer** owner);
|
||||
|
||||
private:
|
||||
typedef DoublyLinkedList<PoolBuffer> BufferList;
|
||||
|
||||
private:
|
||||
PoolBuffer* _AllocateBuffer(size_t size,
|
||||
PoolBuffer** owner, bool* _newBuffer);
|
||||
// object must not be locked
|
||||
|
||||
private:
|
||||
size_t fBlockSize;
|
||||
uint32 fMaxCachedBlocks;
|
||||
uint32 fAllocatedBlocks;
|
||||
BufferList fUnusedBuffers;
|
||||
BufferList fCachedBuffers;
|
||||
BBufferPoolLockable* fLockable;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
} // namespace BHPKG
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_POOL_H_
|
||||
@@ -25,6 +25,9 @@ struct hpkg_header {
|
||||
uint16 version;
|
||||
uint64 total_size;
|
||||
|
||||
// heap
|
||||
// uint64 heap_compression;
|
||||
|
||||
// package attributes section
|
||||
uint32 attributes_compression;
|
||||
uint32 attributes_length_compressed;
|
||||
|
||||
+22
-22
@@ -3,15 +3,15 @@
|
||||
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__HPKG__PRIVATE__BUFFER_CACHE_H_
|
||||
#define _PACKAGE__HPKG__PRIVATE__BUFFER_CACHE_H_
|
||||
#ifndef _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
|
||||
#define _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <util/DoublyLinkedList.h>
|
||||
|
||||
#include <package/hpkg/BufferCache.h>
|
||||
#include <package/hpkg/BufferPool.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
@@ -21,63 +21,63 @@ namespace BHPKG {
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class CachedBuffer : public DoublyLinkedListLinkImpl<CachedBuffer> {
|
||||
class PoolBuffer : public DoublyLinkedListLinkImpl<PoolBuffer> {
|
||||
public:
|
||||
CachedBuffer(size_t size);
|
||||
~CachedBuffer();
|
||||
PoolBuffer(size_t size);
|
||||
~PoolBuffer();
|
||||
|
||||
void* Buffer() const { return fBuffer; }
|
||||
size_t Size() const { return fSize; }
|
||||
|
||||
|
||||
// implementation private
|
||||
CachedBuffer** Owner() const { return fOwner; }
|
||||
void SetOwner(CachedBuffer** owner)
|
||||
PoolBuffer** Owner() const { return fOwner; }
|
||||
void SetOwner(PoolBuffer** owner)
|
||||
{ fOwner = owner; }
|
||||
|
||||
void SetCached(bool cached) { fCached = cached; }
|
||||
bool IsCached() const { return fCached; }
|
||||
|
||||
private:
|
||||
CachedBuffer** fOwner;
|
||||
PoolBuffer** fOwner;
|
||||
void* fBuffer;
|
||||
size_t fSize;
|
||||
bool fCached;
|
||||
};
|
||||
|
||||
|
||||
class CachedBufferPutter {
|
||||
class PoolBufferPutter {
|
||||
public:
|
||||
CachedBufferPutter(BBufferCache* cache, CachedBuffer** owner)
|
||||
PoolBufferPutter(BBufferPool* pool, PoolBuffer** owner)
|
||||
:
|
||||
fCache(cache),
|
||||
fPool(pool),
|
||||
fOwner(owner),
|
||||
fBuffer(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CachedBufferPutter(BBufferCache* cache, CachedBuffer* buffer)
|
||||
PoolBufferPutter(BBufferPool* pool, PoolBuffer* buffer)
|
||||
:
|
||||
fCache(cache),
|
||||
fPool(pool),
|
||||
fOwner(NULL),
|
||||
fBuffer(buffer)
|
||||
{
|
||||
}
|
||||
|
||||
~CachedBufferPutter()
|
||||
~PoolBufferPutter()
|
||||
{
|
||||
if (fCache != NULL) {
|
||||
if (fPool != NULL) {
|
||||
if (fOwner != NULL)
|
||||
fCache->PutBufferAndCache(fOwner);
|
||||
fPool->PutBufferAndCache(fOwner);
|
||||
else if (fBuffer != NULL)
|
||||
fCache->PutBuffer(&fBuffer);
|
||||
fPool->PutBuffer(&fBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BBufferCache* fCache;
|
||||
CachedBuffer** fOwner;
|
||||
CachedBuffer* fBuffer;
|
||||
BBufferPool* fPool;
|
||||
PoolBuffer** fOwner;
|
||||
PoolBuffer* fBuffer;
|
||||
};
|
||||
|
||||
|
||||
@@ -88,4 +88,4 @@ private:
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__HPKG__PRIVATE__BUFFER_CACHE_H_
|
||||
#endif // _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
|
||||
Reference in New Issue
Block a user