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

atomic_shared_ptr.hpp « base - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3059f0dc09d7ae3c1e61a6e48aab63ee3014c925 (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
#pragma once

#include "base/macros.hpp"

#include <memory>

namespace base
{
// Template which provides methods for concurrently using shared pointers.
template <typename T>
class AtomicSharedPtr final
{
public:
  using ContentType = T const;
  using ValueType = std::shared_ptr<ContentType>;

  AtomicSharedPtr() = default;

  void Set(ValueType value) noexcept { atomic_store(&m_wrapped, value); }
  ValueType Get() const noexcept { return atomic_load(&m_wrapped); }

private:
  ValueType m_wrapped = std::make_shared<ContentType>();

  DISALLOW_COPY_AND_MOVE(AtomicSharedPtr);
};
}  // namespace base