Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TRelaxedAtomic.h
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <type_traits>
5
6namespace ph
7{
8
12template<typename T>
13class TRelaxedAtomic final
14{
15public:
17 : m_atomic(T())
18 {}
19
21 : m_atomic(value)
22 {}
23
29 T relaxedRead() const
30 {
31 return m_atomic.load(std::memory_order_relaxed);
32 }
33
39 void relaxedWrite(T value)
40 {
41 m_atomic.store(value, std::memory_order_relaxed);
42 }
43
44 T relaxedFetchAdd(T value)
45 requires std::is_integral_v<T> && std::is_floating_point_v<T>
46 {
47 return m_atomic.fetch_add(value, std::memory_order_relaxed);
48 }
49
50private:
51 std::atomic<T> m_atomic;
52};
53
54}// end namespace ph
Wrapper for relaxed atomic read and write. May resort to lock based read/write if atomic read/write f...
Definition TRelaxedAtomic.h:14
TRelaxedAtomic(T value)
Definition TRelaxedAtomic.h:20
TRelaxedAtomic()
Definition TRelaxedAtomic.h:16
T relaxedRead() const
Definition TRelaxedAtomic.h:29
void relaxedWrite(T value)
Definition TRelaxedAtomic.h:39
T relaxedFetchAdd(T value)
Definition TRelaxedAtomic.h:44
The root for all renderer implementations.
Definition EEngineProject.h:6