mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 21:13:35 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
42
base/shared_buffer_manager.cpp
Normal file
42
base/shared_buffer_manager.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "base/shared_buffer_manager.hpp"
|
||||
|
||||
SharedBufferManager & SharedBufferManager::instance()
|
||||
{
|
||||
static SharedBufferManager i;
|
||||
return i;
|
||||
}
|
||||
|
||||
void SharedBufferManager::clearReserved()
|
||||
{
|
||||
std::lock_guard g(m_mutex);
|
||||
m_sharedBuffers.clear();
|
||||
}
|
||||
|
||||
SharedBufferManager::shared_buffer_ptr_t SharedBufferManager::reserveSharedBuffer(size_t s)
|
||||
{
|
||||
std::lock_guard g(m_mutex);
|
||||
|
||||
shared_buffer_ptr_list_t & l = m_sharedBuffers[s];
|
||||
|
||||
if (l.empty())
|
||||
l.push_back(std::make_shared<shared_buffer_t>(s));
|
||||
|
||||
shared_buffer_ptr_t res = l.front();
|
||||
l.pop_front();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void SharedBufferManager::freeSharedBuffer(size_t s, shared_buffer_ptr_t buf)
|
||||
{
|
||||
std::lock_guard g(m_mutex);
|
||||
|
||||
shared_buffer_ptr_list_t & l = m_sharedBuffers[s];
|
||||
|
||||
l.push_back(buf);
|
||||
}
|
||||
|
||||
uint8_t * SharedBufferManager::GetRawPointer(shared_buffer_ptr_t ptr)
|
||||
{
|
||||
return &((*ptr)[0]);
|
||||
}
|
||||
Reference in New Issue
Block a user