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.
|
* Copyright 2009,2011, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__HPKG__BUFFER_CACHE_H_
|
#ifndef _PACKAGE__HPKG__BUFFER_POOL_H_
|
||||||
#define _PACKAGE__HPKG__BUFFER_CACHE_H_
|
#define _PACKAGE__HPKG__BUFFER_POOL_H_
|
||||||
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@@ -15,31 +15,31 @@ namespace BHPKG {
|
|||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
class CachedBuffer;
|
class PoolBuffer;
|
||||||
}
|
}
|
||||||
using BPrivate::CachedBuffer;
|
using BPrivate::PoolBuffer;
|
||||||
|
|
||||||
|
|
||||||
class BBufferCache {
|
class BBufferPool {
|
||||||
public:
|
public:
|
||||||
virtual ~BBufferCache();
|
virtual ~BBufferPool();
|
||||||
|
|
||||||
virtual CachedBuffer* GetBuffer(size_t size,
|
virtual PoolBuffer* GetBuffer(size_t size,
|
||||||
CachedBuffer** owner = NULL,
|
PoolBuffer** owner = NULL,
|
||||||
bool* _newBuffer = NULL) = 0;
|
bool* _newBuffer = NULL) = 0;
|
||||||
virtual void PutBufferAndCache(CachedBuffer** owner) = 0;
|
virtual void PutBufferAndCache(PoolBuffer** owner) = 0;
|
||||||
// caller is buffer owner and wants the
|
// caller is buffer owner and wants the
|
||||||
// buffer cached, if possible
|
// buffer cached, if possible
|
||||||
virtual void PutBuffer(CachedBuffer** owner) = 0;
|
virtual void PutBuffer(PoolBuffer** owner) = 0;
|
||||||
// puts the buffer for good, owner might
|
// puts the buffer for good, owner might
|
||||||
// have called PutBufferAndCache() before
|
// have called PutBufferAndCache() before
|
||||||
// and might not own a buffer anymore
|
// and might not own a buffer anymore
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BBufferCacheLockable {
|
class BBufferPoolLockable {
|
||||||
public:
|
public:
|
||||||
virtual ~BBufferCacheLockable();
|
virtual ~BBufferPoolLockable();
|
||||||
|
|
||||||
virtual bool Lock() = 0;
|
virtual bool Lock() = 0;
|
||||||
virtual void Unlock() = 0;
|
virtual void Unlock() = 0;
|
||||||
@@ -51,4 +51,4 @@ public:
|
|||||||
} // namespace BPackageKit
|
} // namespace BPackageKit
|
||||||
|
|
||||||
|
|
||||||
#endif // _PACKAGE__HPKG__BUFFER_CACHE_H_
|
#endif // _PACKAGE__HPKG__BUFFER_POOL_H_
|
||||||
@@ -14,21 +14,21 @@ namespace BPackageKit {
|
|||||||
namespace BHPKG {
|
namespace BHPKG {
|
||||||
|
|
||||||
|
|
||||||
class BBufferCache;
|
class BBufferPool;
|
||||||
class BPackageData;
|
class BPackageData;
|
||||||
|
|
||||||
|
|
||||||
class BPackageDataReaderFactory {
|
class BPackageDataReaderFactory {
|
||||||
public:
|
public:
|
||||||
BPackageDataReaderFactory(
|
BPackageDataReaderFactory(
|
||||||
BBufferCache* bufferCache);
|
BBufferPool* bufferPool);
|
||||||
|
|
||||||
status_t CreatePackageDataReader(BDataReader* dataReader,
|
status_t CreatePackageDataReader(BDataReader* dataReader,
|
||||||
const BPackageData& data,
|
const BPackageData& data,
|
||||||
BAbstractBufferedDataReader*& _reader);
|
BAbstractBufferedDataReader*& _reader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBufferCache* fBufferCache;
|
BBufferPool* fBufferPool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace BPackageKit {
|
|||||||
namespace BHPKG {
|
namespace BHPKG {
|
||||||
|
|
||||||
|
|
||||||
class BBufferCache;
|
class BBufferPool;
|
||||||
|
|
||||||
|
|
||||||
namespace V1 {
|
namespace V1 {
|
||||||
@@ -26,14 +26,14 @@ class BPackageData;
|
|||||||
class BPackageDataReaderFactory {
|
class BPackageDataReaderFactory {
|
||||||
public:
|
public:
|
||||||
BPackageDataReaderFactory(
|
BPackageDataReaderFactory(
|
||||||
BBufferCache* bufferCache);
|
BBufferPool* bufferPool);
|
||||||
|
|
||||||
status_t CreatePackageDataReader(BDataReader* dataReader,
|
status_t CreatePackageDataReader(BDataReader* dataReader,
|
||||||
const BPackageData& data,
|
const BPackageData& data,
|
||||||
BAbstractBufferedDataReader*& _reader);
|
BAbstractBufferedDataReader*& _reader);
|
||||||
|
|
||||||
private:
|
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;
|
uint16 version;
|
||||||
uint64 total_size;
|
uint64 total_size;
|
||||||
|
|
||||||
|
// heap
|
||||||
|
// uint64 heap_compression;
|
||||||
|
|
||||||
// package attributes section
|
// package attributes section
|
||||||
uint32 attributes_compression;
|
uint32 attributes_compression;
|
||||||
uint32 attributes_length_compressed;
|
uint32 attributes_length_compressed;
|
||||||
|
|||||||
+22
-22
@@ -3,15 +3,15 @@
|
|||||||
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
|
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PACKAGE__HPKG__PRIVATE__BUFFER_CACHE_H_
|
#ifndef _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
|
||||||
#define _PACKAGE__HPKG__PRIVATE__BUFFER_CACHE_H_
|
#define _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
|
||||||
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <util/DoublyLinkedList.h>
|
#include <util/DoublyLinkedList.h>
|
||||||
|
|
||||||
#include <package/hpkg/BufferCache.h>
|
#include <package/hpkg/BufferPool.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
@@ -21,63 +21,63 @@ namespace BHPKG {
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
class CachedBuffer : public DoublyLinkedListLinkImpl<CachedBuffer> {
|
class PoolBuffer : public DoublyLinkedListLinkImpl<PoolBuffer> {
|
||||||
public:
|
public:
|
||||||
CachedBuffer(size_t size);
|
PoolBuffer(size_t size);
|
||||||
~CachedBuffer();
|
~PoolBuffer();
|
||||||
|
|
||||||
void* Buffer() const { return fBuffer; }
|
void* Buffer() const { return fBuffer; }
|
||||||
size_t Size() const { return fSize; }
|
size_t Size() const { return fSize; }
|
||||||
|
|
||||||
|
|
||||||
// implementation private
|
// implementation private
|
||||||
CachedBuffer** Owner() const { return fOwner; }
|
PoolBuffer** Owner() const { return fOwner; }
|
||||||
void SetOwner(CachedBuffer** owner)
|
void SetOwner(PoolBuffer** owner)
|
||||||
{ fOwner = owner; }
|
{ fOwner = owner; }
|
||||||
|
|
||||||
void SetCached(bool cached) { fCached = cached; }
|
void SetCached(bool cached) { fCached = cached; }
|
||||||
bool IsCached() const { return fCached; }
|
bool IsCached() const { return fCached; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CachedBuffer** fOwner;
|
PoolBuffer** fOwner;
|
||||||
void* fBuffer;
|
void* fBuffer;
|
||||||
size_t fSize;
|
size_t fSize;
|
||||||
bool fCached;
|
bool fCached;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CachedBufferPutter {
|
class PoolBufferPutter {
|
||||||
public:
|
public:
|
||||||
CachedBufferPutter(BBufferCache* cache, CachedBuffer** owner)
|
PoolBufferPutter(BBufferPool* pool, PoolBuffer** owner)
|
||||||
:
|
:
|
||||||
fCache(cache),
|
fPool(pool),
|
||||||
fOwner(owner),
|
fOwner(owner),
|
||||||
fBuffer(NULL)
|
fBuffer(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedBufferPutter(BBufferCache* cache, CachedBuffer* buffer)
|
PoolBufferPutter(BBufferPool* pool, PoolBuffer* buffer)
|
||||||
:
|
:
|
||||||
fCache(cache),
|
fPool(pool),
|
||||||
fOwner(NULL),
|
fOwner(NULL),
|
||||||
fBuffer(buffer)
|
fBuffer(buffer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~CachedBufferPutter()
|
~PoolBufferPutter()
|
||||||
{
|
{
|
||||||
if (fCache != NULL) {
|
if (fPool != NULL) {
|
||||||
if (fOwner != NULL)
|
if (fOwner != NULL)
|
||||||
fCache->PutBufferAndCache(fOwner);
|
fPool->PutBufferAndCache(fOwner);
|
||||||
else if (fBuffer != NULL)
|
else if (fBuffer != NULL)
|
||||||
fCache->PutBuffer(&fBuffer);
|
fPool->PutBuffer(&fBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBufferCache* fCache;
|
BBufferPool* fPool;
|
||||||
CachedBuffer** fOwner;
|
PoolBuffer** fOwner;
|
||||||
CachedBuffer* fBuffer;
|
PoolBuffer* fBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -88,4 +88,4 @@ private:
|
|||||||
} // namespace BPackageKit
|
} // namespace BPackageKit
|
||||||
|
|
||||||
|
|
||||||
#endif // _PACKAGE__HPKG__PRIVATE__BUFFER_CACHE_H_
|
#endif // _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
|
||||||
@@ -23,7 +23,7 @@ HAIKU_PACKAGE_FS_SOURCES =
|
|||||||
AttributeDirectoryCookie.cpp
|
AttributeDirectoryCookie.cpp
|
||||||
AttributeIndex.cpp
|
AttributeIndex.cpp
|
||||||
AutoPackageAttributes.cpp
|
AutoPackageAttributes.cpp
|
||||||
BlockBufferCacheKernel.cpp
|
BlockBufferPoolKernel.cpp
|
||||||
DebugSupport.cpp
|
DebugSupport.cpp
|
||||||
Dependency.cpp
|
Dependency.cpp
|
||||||
Directory.cpp
|
Directory.cpp
|
||||||
@@ -70,14 +70,14 @@ HAIKU_PACKAGE_FS_SHARED_SOURCES =
|
|||||||
;
|
;
|
||||||
|
|
||||||
HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES =
|
HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES =
|
||||||
BlockBufferCacheImpl.cpp
|
BlockBufferPoolImpl.cpp
|
||||||
BufferCache.cpp
|
BufferPool.cpp
|
||||||
CachedBuffer.cpp
|
|
||||||
DataOutput.cpp
|
DataOutput.cpp
|
||||||
DataReader.cpp
|
DataReader.cpp
|
||||||
ErrorOutput.cpp
|
ErrorOutput.cpp
|
||||||
FDDataReader.cpp
|
FDDataReader.cpp
|
||||||
HPKGDefs.cpp
|
HPKGDefs.cpp
|
||||||
|
PoolBuffer.cpp
|
||||||
PackageContentHandler.cpp
|
PackageContentHandler.cpp
|
||||||
PackageData.cpp
|
PackageData.cpp
|
||||||
PackageDataReader.cpp
|
PackageDataReader.cpp
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "BlockBufferCacheKernel.h"
|
|
||||||
|
|
||||||
|
|
||||||
BlockBufferCacheKernel::BlockBufferCacheKernel(size_t blockSize,
|
|
||||||
uint32 maxCachedBlocks)
|
|
||||||
:
|
|
||||||
BlockBufferCacheImpl(blockSize, maxCachedBlocks, this)
|
|
||||||
{
|
|
||||||
mutex_init(&fLock, "BlockBufferCache");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BlockBufferCacheKernel::~BlockBufferCacheKernel()
|
|
||||||
{
|
|
||||||
mutex_destroy(&fLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
BlockBufferCacheKernel::Lock()
|
|
||||||
{
|
|
||||||
mutex_lock(&fLock);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BlockBufferCacheKernel::Unlock()
|
|
||||||
{
|
|
||||||
mutex_unlock(&fLock);
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*/
|
|
||||||
#ifndef BLOCK_BUFFER_CACHE_KERNEL_H
|
|
||||||
#define BLOCK_BUFFER_CACHE_KERNEL_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <lock.h>
|
|
||||||
|
|
||||||
#include <package/hpkg/BlockBufferCacheImpl.h>
|
|
||||||
#include <package/hpkg/BufferCache.h>
|
|
||||||
|
|
||||||
|
|
||||||
using BPackageKit::BHPKG::BBufferCacheLockable;
|
|
||||||
using BPackageKit::BHPKG::BPrivate::BlockBufferCacheImpl;
|
|
||||||
|
|
||||||
|
|
||||||
class BlockBufferCacheKernel
|
|
||||||
: public BlockBufferCacheImpl, BBufferCacheLockable {
|
|
||||||
public:
|
|
||||||
BlockBufferCacheKernel(size_t blockSize,
|
|
||||||
uint32 maxCachedBlocks);
|
|
||||||
virtual ~BlockBufferCacheKernel();
|
|
||||||
|
|
||||||
virtual bool Lock();
|
|
||||||
virtual void Unlock();
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutex fLock;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BLOCK_BUFFER_CACHE_KERNEL_H
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "BlockBufferPoolKernel.h"
|
||||||
|
|
||||||
|
|
||||||
|
BlockBufferPoolKernel::BlockBufferPoolKernel(size_t blockSize,
|
||||||
|
uint32 maxCachedBlocks)
|
||||||
|
:
|
||||||
|
BlockBufferPoolImpl(blockSize, maxCachedBlocks, this)
|
||||||
|
{
|
||||||
|
mutex_init(&fLock, "BlockBufferPool");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BlockBufferPoolKernel::~BlockBufferPoolKernel()
|
||||||
|
{
|
||||||
|
mutex_destroy(&fLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BlockBufferPoolKernel::Lock()
|
||||||
|
{
|
||||||
|
mutex_lock(&fLock);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BlockBufferPoolKernel::Unlock()
|
||||||
|
{
|
||||||
|
mutex_unlock(&fLock);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef BLOCK_BUFFER_POOL_KERNEL_H
|
||||||
|
#define BLOCK_BUFFER_POOL_KERNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <lock.h>
|
||||||
|
|
||||||
|
#include <package/hpkg/BlockBufferPoolImpl.h>
|
||||||
|
#include <package/hpkg/BufferPool.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPackageKit::BHPKG::BBufferPoolLockable;
|
||||||
|
using BPackageKit::BHPKG::BPrivate::BlockBufferPoolImpl;
|
||||||
|
|
||||||
|
|
||||||
|
class BlockBufferPoolKernel : public BlockBufferPoolImpl, BBufferPoolLockable {
|
||||||
|
public:
|
||||||
|
BlockBufferPoolKernel(size_t blockSize,
|
||||||
|
uint32 maxCachedBlocks);
|
||||||
|
virtual ~BlockBufferPoolKernel();
|
||||||
|
|
||||||
|
virtual bool Lock();
|
||||||
|
virtual void Unlock();
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutex fLock;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BLOCK_BUFFER_POOL_KERNEL_H
|
||||||
@@ -20,10 +20,10 @@ static const uint32 kMaxCachedBuffers = 32;
|
|||||||
|
|
||||||
GlobalFactory::GlobalFactory()
|
GlobalFactory::GlobalFactory()
|
||||||
:
|
:
|
||||||
fBufferCache(BPackageKit::BHPKG::B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB,
|
fBufferPool(BPackageKit::BHPKG::B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB,
|
||||||
kMaxCachedBuffers),
|
kMaxCachedBuffers),
|
||||||
fPackageDataReaderFactoryV1(&fBufferCache),
|
fPackageDataReaderFactoryV1(&fBufferPool),
|
||||||
fPackageDataReaderFactoryV2(&fBufferCache)
|
fPackageDataReaderFactoryV2(&fBufferPool)
|
||||||
{
|
{
|
||||||
STATIC_ASSERT((int)BPackageKit::BHPKG::B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB
|
STATIC_ASSERT((int)BPackageKit::BHPKG::B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB
|
||||||
== (int)BPackageKit::BHPKG::V1::B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB);
|
== (int)BPackageKit::BHPKG::V1::B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB);
|
||||||
@@ -93,7 +93,7 @@ GlobalFactory::CreatePackageDataReader(BDataReader* dataReader,
|
|||||||
status_t
|
status_t
|
||||||
GlobalFactory::_Init()
|
GlobalFactory::_Init()
|
||||||
{
|
{
|
||||||
status_t error = fBufferCache.Init();
|
status_t error = fBufferPool.Init();
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <package/hpkg/PackageDataReader.h>
|
#include <package/hpkg/PackageDataReader.h>
|
||||||
#include <package/hpkg/v1/PackageDataReader.h>
|
#include <package/hpkg/v1/PackageDataReader.h>
|
||||||
|
|
||||||
#include "BlockBufferCacheKernel.h"
|
#include "BlockBufferPoolKernel.h"
|
||||||
|
|
||||||
|
|
||||||
using BPackageKit::BHPKG::BDataReader;
|
using BPackageKit::BHPKG::BDataReader;
|
||||||
@@ -44,7 +44,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
static GlobalFactory* sDefaultInstance;
|
static GlobalFactory* sDefaultInstance;
|
||||||
|
|
||||||
BlockBufferCacheKernel fBufferCache;
|
BlockBufferPoolKernel fBufferPool;
|
||||||
BPackageDataReaderFactoryV1 fPackageDataReaderFactoryV1;
|
BPackageDataReaderFactoryV1 fPackageDataReaderFactoryV1;
|
||||||
BPackageDataReaderFactoryV2 fPackageDataReaderFactoryV2;
|
BPackageDataReaderFactoryV2 fPackageDataReaderFactoryV2;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <util/OpenHashTable.h>
|
#include <util/OpenHashTable.h>
|
||||||
|
|
||||||
#include <package/BlockBufferCacheNoLock.h>
|
#include <package/hpkg/BlockBufferPoolNoLock.h>
|
||||||
#include <package/hpkg/PackageContentHandler.h>
|
#include <package/hpkg/PackageContentHandler.h>
|
||||||
#include <package/hpkg/PackageDataReader.h>
|
#include <package/hpkg/PackageDataReader.h>
|
||||||
#include <package/hpkg/PackageEntry.h>
|
#include <package/hpkg/PackageEntry.h>
|
||||||
@@ -41,8 +41,8 @@
|
|||||||
#include "package.h"
|
#include "package.h"
|
||||||
|
|
||||||
|
|
||||||
using BPackageKit::BBlockBufferCacheNoLock;
|
|
||||||
using BPackageKit::BHPKG::BAbstractBufferedDataReader;
|
using BPackageKit::BHPKG::BAbstractBufferedDataReader;
|
||||||
|
using BPackageKit::BHPKG::BBlockBufferPoolNoLock;
|
||||||
using BPackageKit::BHPKG::BBufferDataReader;
|
using BPackageKit::BHPKG::BBufferDataReader;
|
||||||
using BPackageKit::BHPKG::BDataReader;
|
using BPackageKit::BHPKG::BDataReader;
|
||||||
using BPackageKit::BHPKG::BFDDataReader;
|
using BPackageKit::BHPKG::BFDDataReader;
|
||||||
@@ -229,7 +229,7 @@ template<typename VersionPolicy>
|
|||||||
struct PackageContentExtractHandler : VersionPolicy::PackageContentHandler {
|
struct PackageContentExtractHandler : VersionPolicy::PackageContentHandler {
|
||||||
PackageContentExtractHandler(int packageFileFD)
|
PackageContentExtractHandler(int packageFileFD)
|
||||||
:
|
:
|
||||||
fBufferCache(VersionPolicy::kDefaultDataChunkSize, 2),
|
fBufferPool(VersionPolicy::kDefaultDataChunkSize, 2),
|
||||||
fPackageFileReader(packageFileFD),
|
fPackageFileReader(packageFileFD),
|
||||||
fDataBuffer(NULL),
|
fDataBuffer(NULL),
|
||||||
fDataBufferSize(0),
|
fDataBufferSize(0),
|
||||||
@@ -247,7 +247,7 @@ struct PackageContentExtractHandler : VersionPolicy::PackageContentHandler {
|
|||||||
|
|
||||||
status_t Init()
|
status_t Init()
|
||||||
{
|
{
|
||||||
status_t error = fBufferCache.Init();
|
status_t error = fBufferPool.Init();
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -648,7 +648,7 @@ private:
|
|||||||
// create a PackageDataReader
|
// create a PackageDataReader
|
||||||
BAbstractBufferedDataReader* reader;
|
BAbstractBufferedDataReader* reader;
|
||||||
status_t error = typename VersionPolicy::PackageDataReaderFactory(
|
status_t error = typename VersionPolicy::PackageDataReaderFactory(
|
||||||
&fBufferCache)
|
&fBufferPool)
|
||||||
.CreatePackageDataReader(dataReader, data, reader);
|
.CreatePackageDataReader(dataReader, data, reader);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
@@ -688,7 +688,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBlockBufferCacheNoLock fBufferCache;
|
BBlockBufferPoolNoLock fBufferPool;
|
||||||
BFDDataReader fPackageFileReader;
|
BFDDataReader fPackageFileReader;
|
||||||
void* fDataBuffer;
|
void* fDataBuffer;
|
||||||
size_t fDataBufferSize;
|
size_t fDataBufferSize;
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ USES_BE_API on libpackage_build.so = true ;
|
|||||||
|
|
||||||
HPKG_SOURCES =
|
HPKG_SOURCES =
|
||||||
AttributeDataReader.cpp
|
AttributeDataReader.cpp
|
||||||
BlockBufferCache.cpp
|
BlockBufferPool.cpp
|
||||||
BlockBufferCacheImpl.cpp
|
BlockBufferPoolImpl.cpp
|
||||||
BufferCache.cpp
|
BlockBufferPoolNoLock.cpp
|
||||||
CachedBuffer.cpp
|
BufferPool.cpp
|
||||||
|
PoolBuffer.cpp
|
||||||
DataOutput.cpp
|
DataOutput.cpp
|
||||||
DataReader.cpp
|
DataReader.cpp
|
||||||
ErrorOutput.cpp
|
ErrorOutput.cpp
|
||||||
@@ -75,7 +76,6 @@ BuildPlatformSharedLibrary libpackage_build.so
|
|||||||
ActivationTransaction.cpp
|
ActivationTransaction.cpp
|
||||||
AddRepositoryRequest.cpp
|
AddRepositoryRequest.cpp
|
||||||
Attributes.cpp
|
Attributes.cpp
|
||||||
BlockBufferCacheNoLock.cpp
|
|
||||||
ChecksumAccessors.cpp
|
ChecksumAccessors.cpp
|
||||||
Context.cpp
|
Context.cpp
|
||||||
DownloadFileRequest.cpp
|
DownloadFileRequest.cpp
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
|
||||||
* Copyright 2011, Oliver Tappe <[email protected]>
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <package/BlockBufferCacheNoLock.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
|
||||||
|
|
||||||
|
|
||||||
BBlockBufferCacheNoLock::BBlockBufferCacheNoLock(size_t blockSize,
|
|
||||||
uint32 maxCachedBlocks)
|
|
||||||
:
|
|
||||||
BBlockBufferCache(blockSize, maxCachedBlocks)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BBlockBufferCacheNoLock::~BBlockBufferCacheNoLock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
BBlockBufferCacheNoLock::Lock()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BBlockBufferCacheNoLock::Unlock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPackageKit
|
|
||||||
@@ -12,10 +12,10 @@ SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits package solver ] ;
|
|||||||
|
|
||||||
HPKG_SOURCES =
|
HPKG_SOURCES =
|
||||||
AttributeDataReader.cpp
|
AttributeDataReader.cpp
|
||||||
BlockBufferCache.cpp
|
BlockBufferPool.cpp
|
||||||
BlockBufferCacheImpl.cpp
|
BlockBufferPoolImpl.cpp
|
||||||
BufferCache.cpp
|
BlockBufferPoolNoLock.cpp
|
||||||
CachedBuffer.cpp
|
BufferPool.cpp
|
||||||
DataOutput.cpp
|
DataOutput.cpp
|
||||||
DataReader.cpp
|
DataReader.cpp
|
||||||
ErrorOutput.cpp
|
ErrorOutput.cpp
|
||||||
@@ -26,10 +26,12 @@ HPKG_SOURCES =
|
|||||||
PackageDataReader.cpp
|
PackageDataReader.cpp
|
||||||
PackageEntry.cpp
|
PackageEntry.cpp
|
||||||
PackageEntryAttribute.cpp
|
PackageEntryAttribute.cpp
|
||||||
|
PackageFileHeapWriter.cpp
|
||||||
PackageReader.cpp
|
PackageReader.cpp
|
||||||
PackageReaderImpl.cpp
|
PackageReaderImpl.cpp
|
||||||
PackageWriter.cpp
|
PackageWriter.cpp
|
||||||
PackageWriterImpl.cpp
|
PackageWriterImpl.cpp
|
||||||
|
PoolBuffer.cpp
|
||||||
ReaderImplBase.cpp
|
ReaderImplBase.cpp
|
||||||
RepositoryReader.cpp
|
RepositoryReader.cpp
|
||||||
RepositoryReaderImpl.cpp
|
RepositoryReaderImpl.cpp
|
||||||
@@ -66,7 +68,6 @@ SharedLibrary libpackage.so
|
|||||||
ActivationTransaction.cpp
|
ActivationTransaction.cpp
|
||||||
AddRepositoryRequest.cpp
|
AddRepositoryRequest.cpp
|
||||||
Attributes.cpp
|
Attributes.cpp
|
||||||
BlockBufferCacheNoLock.cpp
|
|
||||||
ChecksumAccessors.cpp
|
ChecksumAccessors.cpp
|
||||||
Context.cpp
|
Context.cpp
|
||||||
DaemonClient.cpp
|
DaemonClient.cpp
|
||||||
|
|||||||
+10
-10
@@ -4,11 +4,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <package/hpkg/BlockBufferCache.h>
|
#include <package/hpkg/BlockBufferPool.h>
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <package/hpkg/BlockBufferCacheImpl.h>
|
#include <package/hpkg/BlockBufferPoolImpl.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
@@ -16,22 +16,22 @@ namespace BPackageKit {
|
|||||||
namespace BHPKG {
|
namespace BHPKG {
|
||||||
|
|
||||||
|
|
||||||
BBlockBufferCache::BBlockBufferCache(size_t blockSize, uint32 maxCachedBlocks)
|
BBlockBufferPool::BBlockBufferPool(size_t blockSize, uint32 maxCachedBlocks)
|
||||||
:
|
:
|
||||||
fImpl(new (std::nothrow) BlockBufferCacheImpl(blockSize, maxCachedBlocks,
|
fImpl(new (std::nothrow) BlockBufferPoolImpl(blockSize, maxCachedBlocks,
|
||||||
this))
|
this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBlockBufferCache::~BBlockBufferCache()
|
BBlockBufferPool::~BBlockBufferPool()
|
||||||
{
|
{
|
||||||
delete fImpl;
|
delete fImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BBlockBufferCache::Init()
|
BBlockBufferPool::Init()
|
||||||
{
|
{
|
||||||
if (fImpl == NULL)
|
if (fImpl == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -40,8 +40,8 @@ BBlockBufferCache::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CachedBuffer*
|
PoolBuffer*
|
||||||
BBlockBufferCache::GetBuffer(size_t size, CachedBuffer** owner,
|
BBlockBufferPool::GetBuffer(size_t size, PoolBuffer** owner,
|
||||||
bool* _newBuffer)
|
bool* _newBuffer)
|
||||||
{
|
{
|
||||||
if (fImpl == NULL)
|
if (fImpl == NULL)
|
||||||
@@ -52,7 +52,7 @@ BBlockBufferCache::GetBuffer(size_t size, CachedBuffer** owner,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BBlockBufferCache::PutBufferAndCache(CachedBuffer** owner)
|
BBlockBufferPool::PutBufferAndCache(PoolBuffer** owner)
|
||||||
{
|
{
|
||||||
if (fImpl != NULL)
|
if (fImpl != NULL)
|
||||||
fImpl->PutBufferAndCache(owner);
|
fImpl->PutBufferAndCache(owner);
|
||||||
@@ -60,7 +60,7 @@ BBlockBufferCache::PutBufferAndCache(CachedBuffer** owner)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BBlockBufferCache::PutBuffer(CachedBuffer** owner)
|
BBlockBufferPool::PutBuffer(PoolBuffer** owner)
|
||||||
{
|
{
|
||||||
if (fImpl != NULL)
|
if (fImpl != NULL)
|
||||||
fImpl->PutBuffer(owner);
|
fImpl->PutBuffer(owner);
|
||||||
+25
-25
@@ -5,14 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <package/hpkg/BlockBufferCacheImpl.h>
|
#include <package/hpkg/BlockBufferPoolImpl.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <AutoLocker.h>
|
#include <AutoLocker.h>
|
||||||
|
|
||||||
#include <package/hpkg/CachedBuffer.h>
|
#include <package/hpkg/PoolBuffer.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
@@ -22,11 +22,11 @@ namespace BHPKG {
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - BlockBufferCacheImpl
|
// #pragma mark - BlockBufferPoolImpl
|
||||||
|
|
||||||
|
|
||||||
BlockBufferCacheImpl::BlockBufferCacheImpl(size_t blockSize,
|
BlockBufferPoolImpl::BlockBufferPoolImpl(size_t blockSize,
|
||||||
uint32 maxCachedBlocks, BBufferCacheLockable* lockable)
|
uint32 maxCachedBlocks, BBufferPoolLockable* lockable)
|
||||||
:
|
:
|
||||||
fBlockSize(blockSize),
|
fBlockSize(blockSize),
|
||||||
fMaxCachedBlocks(maxCachedBlocks),
|
fMaxCachedBlocks(maxCachedBlocks),
|
||||||
@@ -36,36 +36,36 @@ BlockBufferCacheImpl::BlockBufferCacheImpl(size_t blockSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BlockBufferCacheImpl::~BlockBufferCacheImpl()
|
BlockBufferPoolImpl::~BlockBufferPoolImpl()
|
||||||
{
|
{
|
||||||
// delete all cached blocks
|
// delete all cached blocks
|
||||||
while (CachedBuffer* block = fCachedBuffers.RemoveHead())
|
while (PoolBuffer* block = fCachedBuffers.RemoveHead())
|
||||||
delete block;
|
delete block;
|
||||||
|
|
||||||
while (CachedBuffer* block = fUnusedBuffers.RemoveHead())
|
while (PoolBuffer* block = fUnusedBuffers.RemoveHead())
|
||||||
delete block;
|
delete block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BlockBufferCacheImpl::Init()
|
BlockBufferPoolImpl::Init()
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CachedBuffer*
|
PoolBuffer*
|
||||||
BlockBufferCacheImpl::GetBuffer(size_t size, CachedBuffer** owner, bool* _newBuffer)
|
BlockBufferPoolImpl::GetBuffer(size_t size, PoolBuffer** owner, bool* _newBuffer)
|
||||||
{
|
{
|
||||||
// for sizes greater than the block size, we always allocate a new buffer
|
// for sizes greater than the block size, we always allocate a new buffer
|
||||||
if (size > fBlockSize)
|
if (size > fBlockSize)
|
||||||
return _AllocateBuffer(size, owner, _newBuffer);
|
return _AllocateBuffer(size, owner, _newBuffer);
|
||||||
|
|
||||||
AutoLocker<BBufferCacheLockable> locker(fLockable);
|
AutoLocker<BBufferPoolLockable> locker(fLockable);
|
||||||
|
|
||||||
// if an owner is given and the buffer is still cached, return it
|
// if an owner is given and the buffer is still cached, return it
|
||||||
if (owner != NULL && *owner != NULL) {
|
if (owner != NULL && *owner != NULL) {
|
||||||
CachedBuffer* buffer = *owner;
|
PoolBuffer* buffer = *owner;
|
||||||
fCachedBuffers.Remove(buffer);
|
fCachedBuffers.Remove(buffer);
|
||||||
|
|
||||||
if (_newBuffer != NULL)
|
if (_newBuffer != NULL)
|
||||||
@@ -74,7 +74,7 @@ BlockBufferCacheImpl::GetBuffer(size_t size, CachedBuffer** owner, bool* _newBuf
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we need a new buffer -- try unused ones first
|
// we need a new buffer -- try unused ones first
|
||||||
CachedBuffer* buffer = fUnusedBuffers.RemoveHead();
|
PoolBuffer* buffer = fUnusedBuffers.RemoveHead();
|
||||||
if (buffer != NULL) {
|
if (buffer != NULL) {
|
||||||
buffer->SetOwner(owner);
|
buffer->SetOwner(owner);
|
||||||
|
|
||||||
@@ -108,9 +108,9 @@ BlockBufferCacheImpl::GetBuffer(size_t size, CachedBuffer** owner, bool* _newBuf
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BlockBufferCacheImpl::PutBufferAndCache(CachedBuffer** owner)
|
BlockBufferPoolImpl::PutBufferAndCache(PoolBuffer** owner)
|
||||||
{
|
{
|
||||||
CachedBuffer* buffer = *owner;
|
PoolBuffer* buffer = *owner;
|
||||||
|
|
||||||
// always delete buffers with non-standard size
|
// always delete buffers with non-standard size
|
||||||
if (buffer->Size() != fBlockSize) {
|
if (buffer->Size() != fBlockSize) {
|
||||||
@@ -119,7 +119,7 @@ BlockBufferCacheImpl::PutBufferAndCache(CachedBuffer** owner)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoLocker<BBufferCacheLockable> locker(fLockable);
|
AutoLocker<BBufferPoolLockable> locker(fLockable);
|
||||||
|
|
||||||
// queue the cached buffer
|
// queue the cached buffer
|
||||||
buffer->SetOwner(owner);
|
buffer->SetOwner(owner);
|
||||||
@@ -128,7 +128,7 @@ BlockBufferCacheImpl::PutBufferAndCache(CachedBuffer** owner)
|
|||||||
|
|
||||||
if (fAllocatedBlocks > fMaxCachedBlocks) {
|
if (fAllocatedBlocks > fMaxCachedBlocks) {
|
||||||
// We have exceeded the limit -- we need to free a buffer.
|
// We have exceeded the limit -- we need to free a buffer.
|
||||||
CachedBuffer* otherBuffer = fUnusedBuffers.RemoveHead();
|
PoolBuffer* otherBuffer = fUnusedBuffers.RemoveHead();
|
||||||
if (otherBuffer == NULL) {
|
if (otherBuffer == NULL) {
|
||||||
otherBuffer = fCachedBuffers.RemoveHead();
|
otherBuffer = fCachedBuffers.RemoveHead();
|
||||||
*otherBuffer->Owner() = NULL;
|
*otherBuffer->Owner() = NULL;
|
||||||
@@ -141,11 +141,11 @@ BlockBufferCacheImpl::PutBufferAndCache(CachedBuffer** owner)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BlockBufferCacheImpl::PutBuffer(CachedBuffer** owner)
|
BlockBufferPoolImpl::PutBuffer(PoolBuffer** owner)
|
||||||
{
|
{
|
||||||
AutoLocker<BBufferCacheLockable> locker(fLockable);
|
AutoLocker<BBufferPoolLockable> locker(fLockable);
|
||||||
|
|
||||||
CachedBuffer* buffer = *owner;
|
PoolBuffer* buffer = *owner;
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -165,11 +165,11 @@ BlockBufferCacheImpl::PutBuffer(CachedBuffer** owner)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CachedBuffer*
|
PoolBuffer*
|
||||||
BlockBufferCacheImpl::_AllocateBuffer(size_t size, CachedBuffer** owner,
|
BlockBufferPoolImpl::_AllocateBuffer(size_t size, PoolBuffer** owner,
|
||||||
bool* _newBuffer)
|
bool* _newBuffer)
|
||||||
{
|
{
|
||||||
CachedBuffer* buffer = new(std::nothrow) CachedBuffer(
|
PoolBuffer* buffer = new(std::nothrow) PoolBuffer(
|
||||||
std::max(size, fBlockSize));
|
std::max(size, fBlockSize));
|
||||||
if (buffer == NULL || buffer->Buffer() == NULL) {
|
if (buffer == NULL || buffer->Buffer() == NULL) {
|
||||||
delete buffer;
|
delete buffer;
|
||||||
@@ -181,7 +181,7 @@ BlockBufferCacheImpl::_AllocateBuffer(size_t size, CachedBuffer** owner,
|
|||||||
if (_newBuffer != NULL)
|
if (_newBuffer != NULL)
|
||||||
*_newBuffer = true;
|
*_newBuffer = true;
|
||||||
|
|
||||||
AutoLocker<BBufferCacheLockable> locker(fLockable);
|
AutoLocker<BBufferPoolLockable> locker(fLockable);
|
||||||
fAllocatedBlocks++;
|
fAllocatedBlocks++;
|
||||||
|
|
||||||
if (owner != NULL)
|
if (owner != NULL)
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
|
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <package/hpkg/BlockBufferPoolNoLock.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPackageKit {
|
||||||
|
|
||||||
|
namespace BHPKG {
|
||||||
|
|
||||||
|
|
||||||
|
BBlockBufferPoolNoLock::BBlockBufferPoolNoLock(size_t blockSize,
|
||||||
|
uint32 maxCachedBlocks)
|
||||||
|
:
|
||||||
|
BBlockBufferPool(blockSize, maxCachedBlocks)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BBlockBufferPoolNoLock::~BBlockBufferPoolNoLock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BBlockBufferPoolNoLock::Lock()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BBlockBufferPoolNoLock::Unlock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BHPKG
|
||||||
|
|
||||||
|
} // namespace BPackageKit
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <package/hpkg/BufferCache.h>
|
#include <package/hpkg/BufferPool.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
@@ -12,12 +12,12 @@ namespace BPackageKit {
|
|||||||
namespace BHPKG {
|
namespace BHPKG {
|
||||||
|
|
||||||
|
|
||||||
BBufferCache::~BBufferCache()
|
BBufferPool::~BBufferPool()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBufferCacheLockable::~BBufferCacheLockable()
|
BBufferPoolLockable::~BBufferPoolLockable()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <package/hpkg/HPKGDefsPrivate.h>
|
#include <package/hpkg/HPKGDefsPrivate.h>
|
||||||
#include <package/hpkg/BufferCache.h>
|
#include <package/hpkg/BufferPool.h>
|
||||||
#include <package/hpkg/CachedBuffer.h>
|
#include <package/hpkg/PoolBuffer.h>
|
||||||
#include <package/hpkg/DataOutput.h>
|
#include <package/hpkg/DataOutput.h>
|
||||||
#include <package/hpkg/PackageData.h>
|
#include <package/hpkg/PackageData.h>
|
||||||
#include <package/hpkg/ZlibDecompressor.h>
|
#include <package/hpkg/ZlibDecompressor.h>
|
||||||
@@ -66,10 +66,10 @@ protected:
|
|||||||
class UncompressedPackageDataReader : public PackageDataReader {
|
class UncompressedPackageDataReader : public PackageDataReader {
|
||||||
public:
|
public:
|
||||||
UncompressedPackageDataReader(BDataReader* dataReader,
|
UncompressedPackageDataReader(BDataReader* dataReader,
|
||||||
BBufferCache* bufferCache)
|
BBufferPool* bufferPool)
|
||||||
:
|
:
|
||||||
PackageDataReader(dataReader),
|
PackageDataReader(dataReader),
|
||||||
fBufferCache(bufferCache)
|
fBufferPool(bufferPool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,11 +107,11 @@ public:
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// get a temporary buffer
|
// get a temporary buffer
|
||||||
CachedBuffer* buffer = fBufferCache->GetBuffer(
|
PoolBuffer* buffer = fBufferPool->GetBuffer(
|
||||||
kUncompressedReaderBufferSize);
|
kUncompressedReaderBufferSize);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
CachedBufferPutter bufferPutter(fBufferCache, &buffer);
|
PoolBufferPutter bufferPutter(fBufferPool, &buffer);
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
// read into the buffer
|
// read into the buffer
|
||||||
@@ -134,7 +134,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBufferCache* fBufferCache;
|
BBufferPool* fBufferPool;
|
||||||
uint64 fOffset;
|
uint64 fOffset;
|
||||||
uint64 fSize;
|
uint64 fSize;
|
||||||
};
|
};
|
||||||
@@ -145,10 +145,10 @@ private:
|
|||||||
|
|
||||||
class ZlibPackageDataReader : public PackageDataReader {
|
class ZlibPackageDataReader : public PackageDataReader {
|
||||||
public:
|
public:
|
||||||
ZlibPackageDataReader(BDataReader* dataReader, BBufferCache* bufferCache)
|
ZlibPackageDataReader(BDataReader* dataReader, BBufferPool* bufferPool)
|
||||||
:
|
:
|
||||||
PackageDataReader(dataReader),
|
PackageDataReader(dataReader),
|
||||||
fBufferCache(bufferCache),
|
fBufferPool(bufferPool),
|
||||||
fUncompressBuffer(NULL),
|
fUncompressBuffer(NULL),
|
||||||
fOffsetTable(NULL)
|
fOffsetTable(NULL)
|
||||||
{
|
{
|
||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
{
|
{
|
||||||
delete[] fOffsetTable;
|
delete[] fOffsetTable;
|
||||||
|
|
||||||
fBufferCache->PutBuffer(&fUncompressBuffer);
|
fBufferPool->PutBuffer(&fUncompressBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t Init(const BPackageData& data)
|
status_t Init(const BPackageData& data)
|
||||||
@@ -218,11 +218,11 @@ public:
|
|||||||
|
|
||||||
// get our uncompressed chunk buffer back, if possible
|
// get our uncompressed chunk buffer back, if possible
|
||||||
bool newBuffer;
|
bool newBuffer;
|
||||||
if (fBufferCache->GetBuffer(fChunkSize, &fUncompressBuffer, &newBuffer)
|
if (fBufferPool->GetBuffer(fChunkSize, &fUncompressBuffer, &newBuffer)
|
||||||
== NULL) {
|
== NULL) {
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
CachedBufferPutter uncompressBufferPutter(fBufferCache,
|
PoolBufferPutter uncompressBufferPutter(fBufferPool,
|
||||||
&fUncompressBuffer);
|
&fUncompressBuffer);
|
||||||
|
|
||||||
if (newBuffer)
|
if (newBuffer)
|
||||||
@@ -281,10 +281,10 @@ private:
|
|||||||
compressedSize);
|
compressedSize);
|
||||||
} else {
|
} else {
|
||||||
// read to a read buffer and uncompress
|
// read to a read buffer and uncompress
|
||||||
CachedBuffer* readBuffer = fBufferCache->GetBuffer(fChunkSize);
|
PoolBuffer* readBuffer = fBufferPool->GetBuffer(fChunkSize);
|
||||||
if (readBuffer == NULL)
|
if (readBuffer == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
CachedBufferPutter readBufferPutter(fBufferCache, readBuffer);
|
PoolBufferPutter readBufferPutter(fBufferPool, readBuffer);
|
||||||
|
|
||||||
error = fDataReader->ReadData(offset, readBuffer->Buffer(),
|
error = fDataReader->ReadData(offset, readBuffer->Buffer(),
|
||||||
compressedSize);
|
compressedSize);
|
||||||
@@ -378,8 +378,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBufferCache* fBufferCache;
|
BBufferPool* fBufferPool;
|
||||||
CachedBuffer* fUncompressBuffer;
|
PoolBuffer* fUncompressBuffer;
|
||||||
int64 fUncompressedChunk;
|
int64 fUncompressedChunk;
|
||||||
|
|
||||||
uint64 fOffset;
|
uint64 fOffset;
|
||||||
@@ -397,9 +397,9 @@ private:
|
|||||||
// #pragma mark - BPackageDataReaderFactory
|
// #pragma mark - BPackageDataReaderFactory
|
||||||
|
|
||||||
|
|
||||||
BPackageDataReaderFactory::BPackageDataReaderFactory(BBufferCache* bufferCache)
|
BPackageDataReaderFactory::BPackageDataReaderFactory(BBufferPool* bufferPool)
|
||||||
:
|
:
|
||||||
fBufferCache(bufferCache)
|
fBufferPool(bufferPool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,11 +413,11 @@ BPackageDataReaderFactory::CreatePackageDataReader(BDataReader* dataReader,
|
|||||||
switch (data.Compression()) {
|
switch (data.Compression()) {
|
||||||
case B_HPKG_COMPRESSION_NONE:
|
case B_HPKG_COMPRESSION_NONE:
|
||||||
reader = new(std::nothrow) UncompressedPackageDataReader(
|
reader = new(std::nothrow) UncompressedPackageDataReader(
|
||||||
dataReader, fBufferCache);
|
dataReader, fBufferPool);
|
||||||
break;
|
break;
|
||||||
case B_HPKG_COMPRESSION_ZLIB:
|
case B_HPKG_COMPRESSION_ZLIB:
|
||||||
reader = new(std::nothrow) ZlibPackageDataReader(dataReader,
|
reader = new(std::nothrow) ZlibPackageDataReader(dataReader,
|
||||||
fBufferCache);
|
fBufferPool);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
#include <package/BlockBufferCacheNoLock.h>
|
#include <package/hpkg/BlockBufferPoolNoLock.h>
|
||||||
|
|
||||||
#include <package/hpkg/PackageAttributeValue.h>
|
#include <package/hpkg/PackageAttributeValue.h>
|
||||||
#include <package/hpkg/PackageContentHandler.h>
|
#include <package/hpkg/PackageContentHandler.h>
|
||||||
#include <package/hpkg/PackageData.h>
|
#include <package/hpkg/PackageData.h>
|
||||||
@@ -879,7 +878,7 @@ PackageWriterImpl::_UpdateReadPackageInfo()
|
|||||||
memcpy(valueBuffer, value.data.raw, value.data.size);
|
memcpy(valueBuffer, value.data.raw, value.data.size);
|
||||||
} else {
|
} else {
|
||||||
// data on heap -- read from there
|
// data on heap -- read from there
|
||||||
BBlockBufferCacheNoLock bufferCache(16 * 1024, 1);
|
BBlockBufferPoolNoLock bufferCache(16 * 1024, 1);
|
||||||
status_t error = bufferCache.Init();
|
status_t error = bufferCache.Init();
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
fListener->PrintError("Failed to initialize buffer cache: %s\n",
|
fListener->PrintError("Failed to initialize buffer cache: %s\n",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <package/hpkg/CachedBuffer.h>
|
#include <package/hpkg/PoolBuffer.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ namespace BHPKG {
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
CachedBuffer::CachedBuffer(size_t size)
|
PoolBuffer::PoolBuffer(size_t size)
|
||||||
:
|
:
|
||||||
fOwner(NULL),
|
fOwner(NULL),
|
||||||
fBuffer(malloc(size)),
|
fBuffer(malloc(size)),
|
||||||
@@ -26,7 +26,7 @@ CachedBuffer::CachedBuffer(size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CachedBuffer::~CachedBuffer()
|
PoolBuffer::~PoolBuffer()
|
||||||
{
|
{
|
||||||
free(fBuffer);
|
free(fBuffer);
|
||||||
}
|
}
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
#include <HashSet.h>
|
#include <HashSet.h>
|
||||||
|
|
||||||
|
#include <package/hpkg/BlockBufferPoolNoLock.h>
|
||||||
#include <package/hpkg/HPKGDefsPrivate.h>
|
#include <package/hpkg/HPKGDefsPrivate.h>
|
||||||
#include <package/hpkg/PackageDataReader.h>
|
#include <package/hpkg/PackageDataReader.h>
|
||||||
#include <package/hpkg/PackageEntry.h>
|
#include <package/hpkg/PackageEntry.h>
|
||||||
#include <package/hpkg/PackageInfoAttributeValue.h>
|
#include <package/hpkg/PackageInfoAttributeValue.h>
|
||||||
#include <package/hpkg/PackageReader.h>
|
#include <package/hpkg/PackageReader.h>
|
||||||
#include <package/BlockBufferCacheNoLock.h>
|
|
||||||
#include <package/ChecksumAccessors.h>
|
#include <package/ChecksumAccessors.h>
|
||||||
#include <package/HashableString.h>
|
#include <package/HashableString.h>
|
||||||
#include <package/PackageInfoContentHandler.h>
|
#include <package/PackageInfoContentHandler.h>
|
||||||
@@ -47,7 +47,7 @@ struct PackageEntryDataFetcher {
|
|||||||
BPackageData& packageData)
|
BPackageData& packageData)
|
||||||
:
|
:
|
||||||
fErrorOutput(errorOutput),
|
fErrorOutput(errorOutput),
|
||||||
fBufferCache(B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB, 2),
|
fBufferPool(B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB, 2),
|
||||||
fPackageData(packageData)
|
fPackageData(packageData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ struct PackageEntryDataFetcher {
|
|||||||
{
|
{
|
||||||
// create a PackageDataReader
|
// create a PackageDataReader
|
||||||
BAbstractBufferedDataReader* reader;
|
BAbstractBufferedDataReader* reader;
|
||||||
status_t result = BPackageDataReaderFactory(&fBufferCache)
|
status_t result = BPackageDataReaderFactory(&fBufferPool)
|
||||||
.CreatePackageDataReader(dataReader, fPackageData, reader);
|
.CreatePackageDataReader(dataReader, fPackageData, reader);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
@@ -81,7 +81,7 @@ struct PackageEntryDataFetcher {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BErrorOutput* fErrorOutput;
|
BErrorOutput* fErrorOutput;
|
||||||
BBlockBufferCacheNoLock fBufferCache;
|
BBlockBufferPoolNoLock fBufferPool;
|
||||||
BPackageData& fPackageData;
|
BPackageData& fPackageData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <package/hpkg/BufferCache.h>
|
#include <package/hpkg/BufferPool.h>
|
||||||
#include <package/hpkg/CachedBuffer.h>
|
#include <package/hpkg/PoolBuffer.h>
|
||||||
#include <package/hpkg/DataOutput.h>
|
#include <package/hpkg/DataOutput.h>
|
||||||
#include <package/hpkg/v1/HPKGDefsPrivate.h>
|
#include <package/hpkg/v1/HPKGDefsPrivate.h>
|
||||||
#include <package/hpkg/v1/PackageData.h>
|
#include <package/hpkg/v1/PackageData.h>
|
||||||
@@ -26,7 +26,7 @@ namespace BHPKG {
|
|||||||
namespace V1 {
|
namespace V1 {
|
||||||
|
|
||||||
|
|
||||||
using BHPKG::BPrivate::CachedBufferPutter;
|
using BHPKG::BPrivate::PoolBufferPutter;
|
||||||
using BHPKG::BPrivate::ZlibDecompressor;
|
using BHPKG::BPrivate::ZlibDecompressor;
|
||||||
|
|
||||||
|
|
||||||
@@ -69,10 +69,10 @@ protected:
|
|||||||
class UncompressedPackageDataReader : public PackageDataReader {
|
class UncompressedPackageDataReader : public PackageDataReader {
|
||||||
public:
|
public:
|
||||||
UncompressedPackageDataReader(BDataReader* dataReader,
|
UncompressedPackageDataReader(BDataReader* dataReader,
|
||||||
BBufferCache* bufferCache)
|
BBufferPool* bufferPool)
|
||||||
:
|
:
|
||||||
PackageDataReader(dataReader),
|
PackageDataReader(dataReader),
|
||||||
fBufferCache(bufferCache)
|
fBufferPool(bufferPool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +110,11 @@ public:
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// get a temporary buffer
|
// get a temporary buffer
|
||||||
CachedBuffer* buffer = fBufferCache->GetBuffer(
|
PoolBuffer* buffer = fBufferPool->GetBuffer(
|
||||||
kUncompressedReaderBufferSize);
|
kUncompressedReaderBufferSize);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
CachedBufferPutter bufferPutter(fBufferCache, &buffer);
|
PoolBufferPutter bufferPutter(fBufferPool, &buffer);
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
// read into the buffer
|
// read into the buffer
|
||||||
@@ -137,7 +137,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBufferCache* fBufferCache;
|
BBufferPool* fBufferPool;
|
||||||
uint64 fOffset;
|
uint64 fOffset;
|
||||||
uint64 fSize;
|
uint64 fSize;
|
||||||
};
|
};
|
||||||
@@ -148,10 +148,10 @@ private:
|
|||||||
|
|
||||||
class ZlibPackageDataReader : public PackageDataReader {
|
class ZlibPackageDataReader : public PackageDataReader {
|
||||||
public:
|
public:
|
||||||
ZlibPackageDataReader(BDataReader* dataReader, BBufferCache* bufferCache)
|
ZlibPackageDataReader(BDataReader* dataReader, BBufferPool* bufferPool)
|
||||||
:
|
:
|
||||||
PackageDataReader(dataReader),
|
PackageDataReader(dataReader),
|
||||||
fBufferCache(bufferCache),
|
fBufferPool(bufferPool),
|
||||||
fUncompressBuffer(NULL),
|
fUncompressBuffer(NULL),
|
||||||
fOffsetTable(NULL)
|
fOffsetTable(NULL)
|
||||||
{
|
{
|
||||||
@@ -161,7 +161,7 @@ public:
|
|||||||
{
|
{
|
||||||
delete[] fOffsetTable;
|
delete[] fOffsetTable;
|
||||||
|
|
||||||
fBufferCache->PutBuffer(&fUncompressBuffer);
|
fBufferPool->PutBuffer(&fUncompressBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t Init(const BPackageData& data)
|
status_t Init(const BPackageData& data)
|
||||||
@@ -221,11 +221,11 @@ public:
|
|||||||
|
|
||||||
// get our uncompressed chunk buffer back, if possible
|
// get our uncompressed chunk buffer back, if possible
|
||||||
bool newBuffer;
|
bool newBuffer;
|
||||||
if (fBufferCache->GetBuffer(fChunkSize, &fUncompressBuffer, &newBuffer)
|
if (fBufferPool->GetBuffer(fChunkSize, &fUncompressBuffer, &newBuffer)
|
||||||
== NULL) {
|
== NULL) {
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
CachedBufferPutter uncompressBufferPutter(fBufferCache,
|
PoolBufferPutter uncompressBufferPutter(fBufferPool,
|
||||||
&fUncompressBuffer);
|
&fUncompressBuffer);
|
||||||
|
|
||||||
if (newBuffer)
|
if (newBuffer)
|
||||||
@@ -284,10 +284,10 @@ private:
|
|||||||
compressedSize);
|
compressedSize);
|
||||||
} else {
|
} else {
|
||||||
// read to a read buffer and uncompress
|
// read to a read buffer and uncompress
|
||||||
CachedBuffer* readBuffer = fBufferCache->GetBuffer(fChunkSize);
|
PoolBuffer* readBuffer = fBufferPool->GetBuffer(fChunkSize);
|
||||||
if (readBuffer == NULL)
|
if (readBuffer == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
CachedBufferPutter readBufferPutter(fBufferCache, readBuffer);
|
PoolBufferPutter readBufferPutter(fBufferPool, readBuffer);
|
||||||
|
|
||||||
error = fDataReader->ReadData(offset, readBuffer->Buffer(),
|
error = fDataReader->ReadData(offset, readBuffer->Buffer(),
|
||||||
compressedSize);
|
compressedSize);
|
||||||
@@ -381,8 +381,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBufferCache* fBufferCache;
|
BBufferPool* fBufferPool;
|
||||||
CachedBuffer* fUncompressBuffer;
|
PoolBuffer* fUncompressBuffer;
|
||||||
int64 fUncompressedChunk;
|
int64 fUncompressedChunk;
|
||||||
|
|
||||||
uint64 fOffset;
|
uint64 fOffset;
|
||||||
@@ -400,9 +400,9 @@ private:
|
|||||||
// #pragma mark - BPackageDataReaderFactory
|
// #pragma mark - BPackageDataReaderFactory
|
||||||
|
|
||||||
|
|
||||||
BPackageDataReaderFactory::BPackageDataReaderFactory(BBufferCache* bufferCache)
|
BPackageDataReaderFactory::BPackageDataReaderFactory(BBufferPool* bufferPool)
|
||||||
:
|
:
|
||||||
fBufferCache(bufferCache)
|
fBufferPool(bufferPool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,11 +416,11 @@ BPackageDataReaderFactory::CreatePackageDataReader(BDataReader* dataReader,
|
|||||||
switch (data.Compression()) {
|
switch (data.Compression()) {
|
||||||
case B_HPKG_COMPRESSION_NONE:
|
case B_HPKG_COMPRESSION_NONE:
|
||||||
reader = new(std::nothrow) UncompressedPackageDataReader(
|
reader = new(std::nothrow) UncompressedPackageDataReader(
|
||||||
dataReader, fBufferCache);
|
dataReader, fBufferPool);
|
||||||
break;
|
break;
|
||||||
case B_HPKG_COMPRESSION_ZLIB:
|
case B_HPKG_COMPRESSION_ZLIB:
|
||||||
reader = new(std::nothrow) ZlibPackageDataReader(dataReader,
|
reader = new(std::nothrow) ZlibPackageDataReader(dataReader,
|
||||||
fBufferCache);
|
fBufferPool);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ BootStaticLibrary boot_packagefs :
|
|||||||
packagefs.cpp
|
packagefs.cpp
|
||||||
|
|
||||||
# package kit
|
# package kit
|
||||||
BlockBufferCacheNoLock.cpp
|
|
||||||
|
|
||||||
# package kit/hpkg
|
# package kit/hpkg
|
||||||
BlockBufferCache.cpp
|
BlockBufferPool.cpp
|
||||||
BlockBufferCacheImpl.cpp
|
BlockBufferPoolImpl.cpp
|
||||||
BufferCache.cpp
|
BlockBufferPoolNoLock.cpp
|
||||||
CachedBuffer.cpp
|
BufferPool.cpp
|
||||||
|
PoolBuffer.cpp
|
||||||
DataOutput.cpp
|
DataOutput.cpp
|
||||||
DataReader.cpp
|
DataReader.cpp
|
||||||
ErrorOutput.cpp
|
ErrorOutput.cpp
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <package/BlockBufferCacheNoLock.h>
|
#include <package/hpkg/BlockBufferPoolNoLock.h>
|
||||||
#include <package/hpkg/DataReader.h>
|
#include <package/hpkg/DataReader.h>
|
||||||
#include <package/hpkg/ErrorOutput.h>
|
#include <package/hpkg/ErrorOutput.h>
|
||||||
#include <package/hpkg/PackageDataReader.h>
|
#include <package/hpkg/PackageDataReader.h>
|
||||||
@@ -272,7 +272,7 @@ struct FileDataReader {
|
|||||||
private:
|
private:
|
||||||
BFDDataReader fDataReader;
|
BFDDataReader fDataReader;
|
||||||
BPackageData fData;
|
BPackageData fData;
|
||||||
BPackageDataReader* fPackageDataReader;
|
BAbstractBufferedDataReader* fPackageDataReader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ struct PackageVolume : BReferenceable {
|
|||||||
private:
|
private:
|
||||||
ino_t fNextNodeID;
|
ino_t fNextNodeID;
|
||||||
PackageDirectory fRootDirectory;
|
PackageDirectory fRootDirectory;
|
||||||
BBlockBufferCacheNoLock fBufferCache;
|
BBlockBufferPoolNoLock fBufferCache;
|
||||||
BPackageDataReaderFactory fDataReaderFactory;
|
BPackageDataReaderFactory fDataReaderFactory;
|
||||||
int fFD;
|
int fFD;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user