mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-10 00:29:59 +00:00
common/thread: Initialize class member variables where applicable
Simplifies the constructor interfaces for Barrier and Event classes.
This commit is contained in:
parent
02602afd10
commit
756e773096
1 changed files with 4 additions and 6 deletions
|
@ -15,8 +15,6 @@ namespace Common {
|
||||||
|
|
||||||
class Event {
|
class Event {
|
||||||
public:
|
public:
|
||||||
Event() : is_set(false) {}
|
|
||||||
|
|
||||||
void Set() {
|
void Set() {
|
||||||
std::lock_guard<std::mutex> lk(mutex);
|
std::lock_guard<std::mutex> lk(mutex);
|
||||||
if (!is_set) {
|
if (!is_set) {
|
||||||
|
@ -48,14 +46,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_set;
|
bool is_set = false;
|
||||||
std::condition_variable condvar;
|
std::condition_variable condvar;
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Barrier {
|
class Barrier {
|
||||||
public:
|
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()
|
/// Blocks until all "count" threads have called Sync()
|
||||||
void Sync() {
|
void Sync() {
|
||||||
|
@ -76,8 +74,8 @@ private:
|
||||||
std::condition_variable condvar;
|
std::condition_variable condvar;
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
const std::size_t count;
|
const std::size_t count;
|
||||||
std::size_t waiting;
|
std::size_t waiting = 0;
|
||||||
std::size_t generation; // Incremented once each time the barrier is used
|
std::size_t generation = 0; // Incremented once each time the barrier is used
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask);
|
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask);
|
||||||
|
|
Loading…
Reference in a new issue