1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-01 12:06:41 +00:00

Replace volatile bools with std::atomic<bool>

This commit is contained in:
Ilya Zhuravlev 2018-12-24 02:49:36 -05:00
parent a037e4c954
commit 07e9ce84b3
4 changed files with 15 additions and 10 deletions

View file

@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <array> #include <array>
#include <atomic>
#include <stdint.h> #include <stdint.h>
@ -279,7 +280,7 @@ private:
std::unique_ptr<Sound_Loudness> mLoudnessAnalyzer; std::unique_ptr<Sound_Loudness> mLoudnessAnalyzer;
volatile bool mIsFinished; std::atomic<bool> mIsFinished;
void updateAll(bool local); void updateAll(bool local);
@ -313,7 +314,7 @@ struct OpenAL_Output::StreamThread : public OpenThreads::Thread {
typedef std::vector<OpenAL_SoundStream*> StreamVec; typedef std::vector<OpenAL_SoundStream*> StreamVec;
StreamVec mStreams; StreamVec mStreams;
volatile bool mQuitNow; std::atomic<bool> mQuitNow;
OpenThreads::Mutex mMutex; OpenThreads::Mutex mMutex;
OpenThreads::Condition mCondVar; OpenThreads::Condition mCondVar;

View file

@ -1,5 +1,7 @@
#include "cellpreloader.hpp" #include "cellpreloader.hpp"
#include <atomic>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/resource/scenemanager.hpp> #include <components/resource/scenemanager.hpp>
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
@ -159,7 +161,7 @@ namespace MWWorld
MWRender::LandManager* mLandManager; MWRender::LandManager* mLandManager;
bool mPreloadInstances; bool mPreloadInstances;
volatile bool mAbort; std::atomic<bool> mAbort;
osg::ref_ptr<Terrain::View> mTerrainView; osg::ref_ptr<Terrain::View> mTerrainView;
@ -392,7 +394,7 @@ namespace MWWorld
} }
private: private:
volatile bool mAbort; std::atomic<bool> mAbort;
std::vector<osg::ref_ptr<Terrain::View> > mTerrainViews; std::vector<osg::ref_ptr<Terrain::View> > mTerrainViews;
Terrain::World* mWorld; Terrain::World* mWorld;
std::vector<osg::Vec3f> mPreloadPositions; std::vector<osg::Vec3f> mPreloadPositions;

View file

@ -9,6 +9,7 @@
#include <osg/Referenced> #include <osg/Referenced>
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <atomic>
#include <queue> #include <queue>
namespace SceneUtil namespace SceneUtil
@ -87,7 +88,7 @@ namespace SceneUtil
private: private:
WorkQueue* mWorkQueue; WorkQueue* mWorkQueue;
volatile bool mActive; std::atomic<bool> mActive;
}; };

View file

@ -2,6 +2,7 @@
#define VIDEOPLAYER_VIDEOSTATE_H #define VIDEOPLAYER_VIDEOSTATE_H
#include <stdint.h> #include <stdint.h>
#include <atomic>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <string> #include <string>
@ -78,7 +79,7 @@ struct PacketQueue {
{ clear(); } { clear(); }
AVPacketList *first_pkt, *last_pkt; AVPacketList *first_pkt, *last_pkt;
volatile bool flushing; std::atomic<bool> flushing;
int nb_packets; int nb_packets;
int size; int size;
@ -169,12 +170,12 @@ struct VideoState {
std::unique_ptr<ParseThread> parse_thread; std::unique_ptr<ParseThread> parse_thread;
std::unique_ptr<VideoThread> video_thread; std::unique_ptr<VideoThread> video_thread;
volatile bool mSeekRequested; std::atomic<bool> mSeekRequested;
uint64_t mSeekPos; uint64_t mSeekPos;
volatile bool mVideoEnded; std::atomic<bool> mVideoEnded;
volatile bool mPaused; std::atomic<bool> mPaused;
volatile bool mQuit; std::atomic<bool> mQuit;
}; };
} }