Welcome to mirror list, hosted at ThFree Co, Russian Federation.

shared_buffer_manager.hpp « base - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c73b9d9215ea4995f9171f98a9a380d557b328bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include "base/mutex.hpp"
#include "std/vector.hpp"
#include "std/shared_ptr.hpp"
#include "std/list.hpp"
#include "std/map.hpp"

class SharedBufferManager
{
public:
  typedef vector<uint8_t> shared_buffer_t;
  typedef shared_ptr<shared_buffer_t> shared_buffer_ptr_t;
  typedef list<shared_buffer_ptr_t> shared_buffer_ptr_list_t;
  typedef map<size_t, shared_buffer_ptr_list_t> shared_buffers_t;
private:

  threads::Mutex m_mutex;
  shared_buffers_t m_sharedBuffers;

public:
  static SharedBufferManager & instance();

  void clearReserved();

  shared_buffer_ptr_t reserveSharedBuffer(size_t s);
  void freeSharedBuffer(size_t s, shared_buffer_ptr_t buf);

  static uint8_t * GetRawPointer(shared_buffer_ptr_t ptr);
};