Returns a buffer, or NULL if no free buffers. LIFO policy is implemented, so we do not touch too many pages (no std::stack though) */
| 94 | pages (no std::stack though) |
| 95 | */ |
| 96 | char *AIO_buffer_cache::acquire_buffer() |
| 97 | { |
| 98 | std::unique_lock<std::mutex> lk(m_mtx); |
| 99 | if (m_cache.empty()) |
| 100 | return nullptr; |
| 101 | auto p= m_cache.back(); |
| 102 | m_cache.pop_back(); |
| 103 | return p; |
| 104 | } |
| 105 | |
| 106 | void AIO_buffer_cache::release_buffer(char *v) |
| 107 | { |