xref: /haiku/headers/os/package/hpkg/BufferPool.h (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
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 
12 namespace BPackageKit {
13 
14 namespace BHPKG {
15 
16 
17 namespace BPrivate {
18 	class PoolBuffer;
19 }
20 using BPrivate::PoolBuffer;
21 
22 
23 class BBufferPool {
24 public:
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 
40 class BBufferPoolLockable {
41 public:
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