btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / package / hpkg / BlockBufferPoolImpl.h
blob8fa4faf25f659db121e8924f85ccaceb3addda0d
1 /*
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.
5 */
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 {
19 namespace BHPKG {
21 namespace BPrivate {
24 class PoolBuffer;
27 class BlockBufferPoolImpl : public BBufferPool {
28 public:
29 BlockBufferPoolImpl(size_t blockSize,
30 uint32 maxCachedBlocks,
31 BBufferPoolLockable* lockable);
32 ~BlockBufferPoolImpl();
34 status_t Init();
36 PoolBuffer* GetBuffer(size_t size,
37 PoolBuffer** owner = NULL,
38 bool* _newBuffer = NULL);
39 void PutBufferAndCache(PoolBuffer** owner);
40 void PutBuffer(PoolBuffer** owner);
42 private:
43 typedef DoublyLinkedList<PoolBuffer> BufferList;
45 private:
46 PoolBuffer* _AllocateBuffer(size_t size,
47 PoolBuffer** owner, bool* _newBuffer);
48 // object must not be locked
50 private:
51 size_t fBlockSize;
52 uint32 fMaxCachedBlocks;
53 uint32 fAllocatedBlocks;
54 BufferList fUnusedBuffers;
55 BufferList fCachedBuffers;
56 BBufferPoolLockable* fLockable;
60 } // namespace BPrivate
62 } // namespace BHPKG
64 } // namespace BPackageKit
67 #endif // _PACKAGE__HPKG__PRIVATE__BLOCK_BUFFER_POOL_H_