From 756e773096c5a64cb5c0ff48104ceb36fa1935cb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Nov 2018 21:44:58 -0500 Subject: common/thread: Initialize class member variables where applicable Simplifies the constructor interfaces for Barrier and Event classes. --- src/common/thread.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/common/thread.h') diff --git a/src/common/thread.h b/src/common/thread.h index 816183bc8..741dce487 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -15,8 +15,6 @@ namespace Common { class Event { public: - Event() : is_set(false) {} - void Set() { std::lock_guard lk(mutex); if (!is_set) { @@ -48,14 +46,14 @@ public: } private: - bool is_set; + bool is_set = false; std::condition_variable condvar; std::mutex mutex; }; class Barrier { public: - explicit Barrier(std::size_t count_) : count(count_), waiting(0), generation(0) {} + explicit Barrier(std::size_t count_) : count(count_) {} /// Blocks until all "count" threads have called Sync() void Sync() { @@ -76,8 +74,8 @@ private: std::condition_variable condvar; std::mutex mutex; const std::size_t count; - std::size_t waiting; - std::size_t generation; // Incremented once each time the barrier is used + std::size_t waiting = 0; + std::size_t generation = 0; // Incremented once each time the barrier is used }; void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask); -- cgit v1.2.3