From 03d3563ef95efc6ab8076d66ebda48545c6089c4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 15 May 2019 16:22:24 +0100 Subject: Replace socketengine_{pthread,win32} with C++11 threads. --- include/configreader.h | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'include/configreader.h') diff --git a/include/configreader.h b/include/configreader.h index f9b9b582b..a7105ea7f 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -461,24 +461,35 @@ class CoreExport ServerConfig */ class CoreExport ConfigReaderThread : public Thread { - ServerConfig* Config; - volatile bool done; + private: + /** The new server configuration. */ + ServerConfig* Config = new ServerConfig(); + + /** Whether the config has been read yet. */ + std::atomic_bool done = { false }; + + protected: + /** @copydoc Thread::OnStart */ + void OnStart() override; + + /** @copydoc Thread::OnStop */ + void OnStop() override; + public: - const std::string TheUserUID; - ConfigReaderThread(const std::string &useruid) - : Config(new ServerConfig), done(false), TheUserUID(useruid) + const std::string UUID; + + ConfigReaderThread(const std::string& uuid) + : UUID(uuid) { } - virtual ~ConfigReaderThread() + ~ConfigReaderThread() { delete Config; } - void Run() override; - /** Run in the main thread to apply the configuration */ - void Finish(); - bool IsDone() { return done; } + /** Whether the configuration has been read yet. */ + bool IsDone() { return done.load(); } }; class CoreExport ConfigStatus -- cgit v1.3.1-10-gc9f91