aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/Atomic.hpp
blob: 9015c60038bca655ec8e8e9089c9e06afb1c0748 (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
31
32
33
#ifndef EFSW_ATOMIC_BOOL_HPP
#define EFSW_ATOMIC_BOOL_HPP

#include <efsw/base.hpp>

#include <atomic>

namespace efsw {

template <typename T> class Atomic {
  public:
	explicit Atomic( T set = false ) : set_( set ) {}

	Atomic& operator=( T set ) {
		set_.store( set, std::memory_order_release );
		return *this;
	}

	explicit operator T() const {
		return set_.load( std::memory_order_acquire );
	}

	T load() const {
		return set_.load( std::memory_order_acquire );
	}

  private:
	std::atomic<T> set_;
};

} // namespace efsw

#endif