1/* 2 * Copyright 2009,2011, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _PACKAGE__HPKG__BUFFER_POOL_H_ 6#define _PACKAGE__HPKG__BUFFER_POOL_H_ 7 8 9#include <stddef.h> 10 11 12namespace BPackageKit { 13 14namespace BHPKG { 15 16 17namespace BPrivate { 18 class PoolBuffer; 19} 20using BPrivate::PoolBuffer; 21 22 23class BBufferPool { 24public: 25 virtual ~BBufferPool(); 26 27 virtual PoolBuffer* GetBuffer(size_t size, 28 PoolBuffer** owner = NULL, 29 bool* _newBuffer = NULL) = 0; 30 virtual void PutBufferAndCache(PoolBuffer** owner) = 0; 31 // caller is buffer owner and wants the 32 // buffer cached, if possible 33 virtual void PutBuffer(PoolBuffer** owner) = 0; 34 // puts the buffer for good, owner might 35 // have called PutBufferAndCache() before 36 // and might not own a buffer anymore 37}; 38 39 40class BBufferPoolLockable { 41public: 42 virtual ~BBufferPoolLockable(); 43 44 virtual bool Lock() = 0; 45 virtual void Unlock() = 0; 46}; 47 48 49} // namespace BHPKG 50 51} // namespace BPackageKit 52 53 54#endif // _PACKAGE__HPKG__BUFFER_POOL_H_ 55