2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
4 * Distributed under the terms of the MIT License.
6 #ifndef _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_POOL_H_
7 #define _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_POOL_H_
10 #include <SupportDefs.h>
12 #include <util/DoublyLinkedList.h>
14 #include <package/hpkg/BufferPool.h>
17 namespace BPackageKit
{
27 class BlockBufferPoolImpl
: public BBufferPool
{
29 BlockBufferPoolImpl(size_t blockSize
,
30 uint32 maxCachedBlocks
,
31 BBufferPoolLockable
* lockable
);
32 ~BlockBufferPoolImpl();
36 PoolBuffer
* GetBuffer(size_t size
,
37 PoolBuffer
** owner
= NULL
,
38 bool* _newBuffer
= NULL
);
39 void PutBufferAndCache(PoolBuffer
** owner
);
40 void PutBuffer(PoolBuffer
** owner
);
43 typedef DoublyLinkedList
<PoolBuffer
> BufferList
;
46 PoolBuffer
* _AllocateBuffer(size_t size
,
47 PoolBuffer
** owner
, bool* _newBuffer
);
48 // object must not be locked
52 uint32 fMaxCachedBlocks
;
53 uint32 fAllocatedBlocks
;
54 BufferList fUnusedBuffers
;
55 BufferList fCachedBuffers
;
56 BBufferPoolLockable
* fLockable
;
60 } // namespace BPrivate
64 } // namespace BPackageKit
67 #endif // _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_POOL_H_