mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 16:23:39 +02:00
Use atomic<bool> and compare_exchange_strong
This commit is contained in:
parent
a2a6cd0c7a
commit
67d43b4fac
2 changed files with 8 additions and 9 deletions
|
@ -275,7 +275,7 @@ private:
|
|||
switch ((int)event->type()) {
|
||||
case ApplicationEvent::Render:
|
||||
render();
|
||||
qApp->_pendingRenderEventCount--;
|
||||
qApp->_pendingRenderEvent.store(false);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -2723,13 +2723,12 @@ bool Application::importFromZIP(const QString& filePath) {
|
|||
|
||||
// thread-safe
|
||||
void Application::onPresent(quint32 frameCount) {
|
||||
if (_pendingIdleEventCount.load() == 0) {
|
||||
_pendingIdleEventCount++;
|
||||
bool expected = false;
|
||||
if (_pendingIdleEvent.compare_exchange_strong(expected, true)) {
|
||||
postEvent(this, new QEvent((QEvent::Type)ApplicationEvent::Idle), Qt::HighEventPriority);
|
||||
}
|
||||
|
||||
if (_renderEventHandler && !isAboutToQuit() && _pendingRenderEventCount.load() == 0) {
|
||||
_pendingRenderEventCount++;
|
||||
expected = false;
|
||||
if (_renderEventHandler && !isAboutToQuit() && _pendingRenderEvent.compare_exchange_strong(expected, true)) {
|
||||
postEvent(_renderEventHandler, new QEvent((QEvent::Type)ApplicationEvent::Render));
|
||||
}
|
||||
}
|
||||
|
@ -2845,7 +2844,7 @@ bool Application::event(QEvent* event) {
|
|||
}
|
||||
#endif // DEBUG_EVENT_QUEUE
|
||||
|
||||
_pendingIdleEventCount--;
|
||||
_pendingIdleEvent.store(false);
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
@ -718,7 +718,7 @@ private:
|
|||
|
||||
friend class RenderEventHandler;
|
||||
|
||||
std::atomic<int> _pendingIdleEventCount { 0 };
|
||||
std::atomic<int> _pendingRenderEventCount { 0 };
|
||||
std::atomic<bool> _pendingIdleEvent { false };
|
||||
std::atomic<bool> _pendingRenderEvent { false };
|
||||
};
|
||||
#endif // hifi_Application_h
|
||||
|
|
Loading…
Reference in a new issue