diff options
| author | 2019-04-01 12:29:59 -0400 | |
|---|---|---|
| committer | 2019-04-01 12:53:47 -0400 | |
| commit | 781ab8407b50d303197ab6fb888ed35ecbcce23a (patch) | |
| tree | eaf2aabd5471c13fe89ac5f7da247b3bf1248e83 /src/core/perf_stats.cpp | |
| parent | Merge pull request #2304 from lioncash/memsize (diff) | |
| download | yuzu-781ab8407b50d303197ab6fb888ed35ecbcce23a.tar.gz yuzu-781ab8407b50d303197ab6fb888ed35ecbcce23a.tar.xz yuzu-781ab8407b50d303197ab6fb888ed35ecbcce23a.zip | |
general: Use deducation guides for std::lock_guard and std::unique_lock
Since C++17, the introduction of deduction guides for locking facilities
means that we no longer need to hardcode the mutex type into the locks
themselves, making it easier to switch mutex types, should it ever be
necessary in the future.
Diffstat (limited to 'src/core/perf_stats.cpp')
| -rw-r--r-- | src/core/perf_stats.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index c716a462b..4afd6c8a3 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp | |||
| @@ -18,13 +18,13 @@ using std::chrono::microseconds; | |||
| 18 | namespace Core { | 18 | namespace Core { |
| 19 | 19 | ||
| 20 | void PerfStats::BeginSystemFrame() { | 20 | void PerfStats::BeginSystemFrame() { |
| 21 | std::lock_guard<std::mutex> lock(object_mutex); | 21 | std::lock_guard lock{object_mutex}; |
| 22 | 22 | ||
| 23 | frame_begin = Clock::now(); | 23 | frame_begin = Clock::now(); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | void PerfStats::EndSystemFrame() { | 26 | void PerfStats::EndSystemFrame() { |
| 27 | std::lock_guard<std::mutex> lock(object_mutex); | 27 | std::lock_guard lock{object_mutex}; |
| 28 | 28 | ||
| 29 | auto frame_end = Clock::now(); | 29 | auto frame_end = Clock::now(); |
| 30 | accumulated_frametime += frame_end - frame_begin; | 30 | accumulated_frametime += frame_end - frame_begin; |
| @@ -35,13 +35,13 @@ void PerfStats::EndSystemFrame() { | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void PerfStats::EndGameFrame() { | 37 | void PerfStats::EndGameFrame() { |
| 38 | std::lock_guard<std::mutex> lock(object_mutex); | 38 | std::lock_guard lock{object_mutex}; |
| 39 | 39 | ||
| 40 | game_frames += 1; | 40 | game_frames += 1; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us) { | 43 | PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us) { |
| 44 | std::lock_guard<std::mutex> lock(object_mutex); | 44 | std::lock_guard lock{object_mutex}; |
| 45 | 45 | ||
| 46 | const auto now = Clock::now(); | 46 | const auto now = Clock::now(); |
| 47 | // Walltime elapsed since stats were reset | 47 | // Walltime elapsed since stats were reset |
| @@ -67,7 +67,7 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | double PerfStats::GetLastFrameTimeScale() { | 69 | double PerfStats::GetLastFrameTimeScale() { |
| 70 | std::lock_guard<std::mutex> lock(object_mutex); | 70 | std::lock_guard lock{object_mutex}; |
| 71 | 71 | ||
| 72 | constexpr double FRAME_LENGTH = 1.0 / 60; | 72 | constexpr double FRAME_LENGTH = 1.0 / 60; |
| 73 | return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH; | 73 | return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH; |