simdjson  3.11.0
Ridiculously Fast JSON
atomic_ptr.h
1 #ifndef SIMDJSON_INTERNAL_ATOMIC_PTR_H
2 #define SIMDJSON_INTERNAL_ATOMIC_PTR_H
3 
4 #include "simdjson/base.h"
5 #include <atomic>
6 
7 namespace simdjson {
8 namespace internal {
9 
10 template<typename T>
11 class atomic_ptr {
12 public:
13  atomic_ptr(T *_ptr) : ptr{_ptr} {}
14 
15  operator const T*() const { return ptr.load(); }
16  const T& operator*() const { return *ptr; }
17  const T* operator->() const { return ptr.load(); }
18 
19  operator T*() { return ptr.load(); }
20  T& operator*() { return *ptr; }
21  T* operator->() { return ptr.load(); }
22  atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; }
23 
24 private:
25  std::atomic<T*> ptr;
26 };
27 
28 } // namespace internal
29 } // namespace simdjson
30 
31 #endif // SIMDJSON_INTERNAL_ATOMIC_PTR_H
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8