MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / needsRefresh

Method needsRefresh

dependencies/hueplusplus-1.0.0/src/APICache.cpp:137–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137bool APICache::needsRefresh()
138{
139 using clock = std::chrono::steady_clock;
140 if (base)
141 {
142 // Update lastRefresh in case base was refreshed
143 lastRefresh = std::max(lastRefresh, base->lastRefresh);
144 }
145
146 // Explicitly check for zero in case refreshDuration is duration::max()
147 // Negative duration causes overflow check to overflow itself
148 if (lastRefresh.time_since_epoch().count() == 0 || refreshDuration.count() < 0)
149 {
150 // No value set yet
151 return true;
152 }
153 // Check if nextRefresh would overflow (assumes lastRefresh is not negative, which it should not be).
154 // If addition would overflow, do not refresh
155 else if (clock::duration::max() - refreshDuration > lastRefresh.time_since_epoch())
156 {
157 clock::time_point nextRefresh = lastRefresh + refreshDuration;
158 if (clock::now() >= nextRefresh)
159 {
160 return true;
161 }
162 }
163 return false;
164}
165
166std::string APICache::getRequestPath() const
167{

Callers 1

refreshMethod · 0.80

Calls 1

countMethod · 0.45

Tested by

no test coverage detected