diff options
| author | 2018-11-21 21:44:58 -0500 | |
|---|---|---|
| committer | 2018-11-21 21:45:01 -0500 | |
| commit | 756e773096c5a64cb5c0ff48104ceb36fa1935cb (patch) | |
| tree | 0f6cc34f9bf1213cfa8fd3faca64b8cd7d43b591 /src | |
| parent | common/thread: Group non-member functions together (diff) | |
| download | yuzu-756e773096c5a64cb5c0ff48104ceb36fa1935cb.tar.gz yuzu-756e773096c5a64cb5c0ff48104ceb36fa1935cb.tar.xz yuzu-756e773096c5a64cb5c0ff48104ceb36fa1935cb.zip | |
common/thread: Initialize class member variables where applicable
Simplifies the constructor interfaces for Barrier and Event classes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/thread.h | 10 |
1 files changed, 4 insertions, 6 deletions
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 { | |||
| 15 | 15 | ||
| 16 | class Event { | 16 | class Event { |
| 17 | public: | 17 | public: |
| 18 | Event() : is_set(false) {} | ||
| 19 | |||
| 20 | void Set() { | 18 | void Set() { |
| 21 | std::lock_guard<std::mutex> lk(mutex); | 19 | std::lock_guard<std::mutex> lk(mutex); |
| 22 | if (!is_set) { | 20 | if (!is_set) { |
| @@ -48,14 +46,14 @@ public: | |||
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | private: | 48 | private: |
| 51 | bool is_set; | 49 | bool is_set = false; |
| 52 | std::condition_variable condvar; | 50 | std::condition_variable condvar; |
| 53 | std::mutex mutex; | 51 | std::mutex mutex; |
| 54 | }; | 52 | }; |
| 55 | 53 | ||
| 56 | class Barrier { | 54 | class Barrier { |
| 57 | public: | 55 | public: |
| 58 | explicit Barrier(std::size_t count_) : count(count_), waiting(0), generation(0) {} | 56 | explicit Barrier(std::size_t count_) : count(count_) {} |
| 59 | 57 | ||
| 60 | /// Blocks until all "count" threads have called Sync() | 58 | /// Blocks until all "count" threads have called Sync() |
| 61 | void Sync() { | 59 | void Sync() { |
| @@ -76,8 +74,8 @@ private: | |||
| 76 | std::condition_variable condvar; | 74 | std::condition_variable condvar; |
| 77 | std::mutex mutex; | 75 | std::mutex mutex; |
| 78 | const std::size_t count; | 76 | const std::size_t count; |
| 79 | std::size_t waiting; | 77 | std::size_t waiting = 0; |
| 80 | std::size_t generation; // Incremented once each time the barrier is used | 78 | std::size_t generation = 0; // Incremented once each time the barrier is used |
| 81 | }; | 79 | }; |
| 82 | 80 | ||
| 83 | void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask); | 81 | void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask); |