libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
bufferpool.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_CORE
13#include <cstddef>
14#include <promeki/namespace.h>
15#include <promeki/buffer.h>
16#include <promeki/list.h>
17#include <promeki/memspace.h>
18
19PROMEKI_NAMESPACE_BEGIN
20
67class BufferPool {
68 public:
70 BufferPool() = default;
71
78 BufferPool(size_t bufferSize, size_t alignment = 0, const MemSpace &ms = MemSpace::Default);
79
81 ~BufferPool() = default;
82
83 BufferPool(const BufferPool &) = delete;
84 BufferPool &operator=(const BufferPool &) = delete;
85 BufferPool(BufferPool &&) noexcept = default;
86 BufferPool &operator=(BufferPool &&) noexcept = default;
87
89 size_t bufferSize() const { return _bufferSize; }
90
92 size_t alignment() const { return _alignment; }
93
95 size_t available() const { return _free.size(); }
96
103 void reserve(size_t count);
104
115 Buffer acquire();
116
127 void release(Buffer &&buf);
128
130 void clear();
131
132 private:
133 size_t _bufferSize = 0;
134 size_t _alignment = 0;
135 MemSpace _memSpace;
136 List<Buffer> _free;
137};
138
139PROMEKI_NAMESPACE_END
140
141#endif // PROMEKI_ENABLE_CORE