Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
buffer_pool.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Roc authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_core/buffer_pool.h
10 //! @brief Buffer pool.
11 
12 #ifndef ROC_CORE_BUFFER_POOL_H_
13 #define ROC_CORE_BUFFER_POOL_H_
14 
15 #include "roc_core/pool.h"
16 
17 namespace roc {
18 namespace core {
19 
20 template <class T> class Buffer;
21 
22 //! Buffer pool.
23 template <class T> class BufferPool : public Pool<Buffer<T> > {
24 public:
25  //! Initialization.
26  BufferPool(IAllocator& allocator, size_t buff_size, bool poison)
27  : Pool<Buffer<T> >(allocator, sizeof(Buffer<T>) + sizeof(T) * buff_size, poison)
28  , buff_size_(buff_size) {
29  }
30 
31  //! Get buffer size (number of elements in buffer).
32  size_t buffer_size() const {
33  return buff_size_;
34  }
35 
36 private:
37  size_t buff_size_;
38 };
39 
40 } // namespace core
41 } // namespace roc
42 
43 #endif // ROC_CORE_BUFFER_POOL_H_
Memory allocator interface.
Definition: iallocator.h:23
Pool.
Root namespace.
Buffer pool.
Definition: buffer_pool.h:23
Buffer.
Definition: buffer.h:23
size_t buffer_size() const
Get buffer size (number of elements in buffer).
Definition: buffer_pool.h:32
Pool.
Definition: pool.h:35
BufferPool(IAllocator &allocator, size_t buff_size, bool poison)
Initialization.
Definition: buffer_pool.h:26