2011-01-30 18:05:38 +03:00
|
|
|
/*
|
2011-01-30 18:15:33 +03:00
|
|
|
* Copyright 2009,2011, Haiku, Inc.
|
2011-01-30 18:05:38 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2013-05-14 20:59:57 +04:00
|
|
|
#ifndef _PACKAGE__HPKG__BUFFER_POOL_H_
|
|
|
|
#define _PACKAGE__HPKG__BUFFER_POOL_H_
|
2011-01-30 18:05:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
|
|
|
|
namespace BHPKG {
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
2013-05-14 20:59:57 +04:00
|
|
|
class PoolBuffer;
|
2011-01-30 18:05:38 +03:00
|
|
|
}
|
2013-05-14 20:59:57 +04:00
|
|
|
using BPrivate::PoolBuffer;
|
2011-01-30 18:05:38 +03:00
|
|
|
|
|
|
|
|
2013-05-14 20:59:57 +04:00
|
|
|
class BBufferPool {
|
2011-01-30 18:05:38 +03:00
|
|
|
public:
|
2013-05-14 20:59:57 +04:00
|
|
|
virtual ~BBufferPool();
|
2011-01-30 18:05:38 +03:00
|
|
|
|
2013-05-14 20:59:57 +04:00
|
|
|
virtual PoolBuffer* GetBuffer(size_t size,
|
|
|
|
PoolBuffer** owner = NULL,
|
2011-01-30 18:05:38 +03:00
|
|
|
bool* _newBuffer = NULL) = 0;
|
2013-05-14 20:59:57 +04:00
|
|
|
virtual void PutBufferAndCache(PoolBuffer** owner) = 0;
|
2011-01-30 18:05:38 +03:00
|
|
|
// caller is buffer owner and wants the
|
|
|
|
// buffer cached, if possible
|
2013-05-14 20:59:57 +04:00
|
|
|
virtual void PutBuffer(PoolBuffer** owner) = 0;
|
2011-01-30 18:05:38 +03:00
|
|
|
// puts the buffer for good, owner might
|
|
|
|
// have called PutBufferAndCache() before
|
|
|
|
// and might not own a buffer anymore
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-14 20:59:57 +04:00
|
|
|
class BBufferPoolLockable {
|
2011-01-30 18:05:38 +03:00
|
|
|
public:
|
2013-05-14 20:59:57 +04:00
|
|
|
virtual ~BBufferPoolLockable();
|
2011-01-30 18:05:38 +03:00
|
|
|
|
|
|
|
virtual bool Lock() = 0;
|
|
|
|
virtual void Unlock() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace BHPKG
|
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2013-05-14 20:59:57 +04:00
|
|
|
#endif // _PACKAGE__HPKG__BUFFER_POOL_H_
|