| 58 | }; |
| 59 | |
| 60 | class IoBufferPool { |
| 61 | private: |
| 62 | mutex m_mutex; |
| 63 | static const size_t m_max_size = 70*1024*1024; |
| 64 | size_t m_current_size; |
| 65 | list<IoBuffer*> m_buffers; |
| 66 | |
| 67 | IoBufferPool() : m_current_size(0) {}; |
| 68 | |
| 69 | public: |
| 70 | |
| 71 | // the size below is to accomodate the maximum i/o buffer size + enough IVs to write up to 64MB |
| 72 | static const size_t m_max_pool_buffer_size = ((MAX_IO_BUFFER_KB * 1024) / PLAIN_BS) * CIPHER_BS + ((64 * 1024 * 1024) / PLAIN_BS) * BLOCK_IV_LEN; |
| 73 | |
| 74 | static IoBufferPool& getInstance(); |
| 75 | |
| 76 | // disallow copying and moving |
| 77 | IoBufferPool(IoBufferPool const&) = delete; |
| 78 | void operator=(IoBufferPool const&) = delete; |
| 79 | IoBufferPool(IoBufferPool const&&) = delete; |
| 80 | void operator=(IoBufferPool const&&) = delete; |
| 81 | |
| 82 | ~IoBufferPool(); |
| 83 | IoBuffer *GetIoBuffer(size_t buffer_size, size_t ivbufer_size); |
| 84 | void ReleaseIoBuffer(IoBuffer *pBuf); |
| 85 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected