SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
qsg2dasyncresult.h
Go to the documentation of this file.
1
30#ifndef OPENSWMM_RENDER_QSG2DASYNCRESULT_H
31#define OPENSWMM_RENDER_QSG2DASYNCRESULT_H
32
33#include <QtGlobal>
34
35#include <utility>
36
37namespace OpenSWMM::Render
38{
39
40template <typename T>
42{
43public:
46 quint64 beginJob() { return ++m_submitted; }
47
51 {
52 ++m_submitted;
53 m_published = 0;
54 m_value = T{};
55 }
56
58 bool tryPublish(quint64 generation, T &&value)
59 {
60 if (generation != m_submitted) return false; // stale — dropped
61 m_value = std::move(value);
62 m_published = generation;
63 return true;
64 }
65
69 [[nodiscard]] bool upToDate() const
70 {
71 return m_published != 0 && m_published == m_submitted;
72 }
73
74 [[nodiscard]] bool hasValue() const { return m_published != 0; }
75 [[nodiscard]] bool jobPending() const
76 {
77 return m_submitted != 0 && m_published != m_submitted;
78 }
79
80 [[nodiscard]] const T &value() const { return m_value; }
81 [[nodiscard]] quint64 currentGeneration() const { return m_submitted; }
82
83private:
84 T m_value{};
85 quint64 m_submitted = 0;
86 quint64 m_published = 0;
87};
88
89} // namespace OpenSWMM::Render
90
91#endif // OPENSWMM_RENDER_QSG2DASYNCRESULT_H
Definition qsg2dasyncresult.h:42
bool tryPublish(quint64 generation, T &&value)
Definition qsg2dasyncresult.h:58
const T & value() const
Definition qsg2dasyncresult.h:80
bool upToDate() const
Definition qsg2dasyncresult.h:69
quint64 beginJob()
Definition qsg2dasyncresult.h:46
bool jobPending() const
Definition qsg2dasyncresult.h:75
bool hasValue() const
Definition qsg2dasyncresult.h:74
void invalidate()
Definition qsg2dasyncresult.h:50
quint64 currentGeneration() const
Definition qsg2dasyncresult.h:81
Definition gisrasterlayer.h:40