core: Replace lock_guard with scoped_lock
This commit is contained in:
parent
1f275eb077
commit
6a071c42d2
@ -53,13 +53,13 @@ PerfStats::~PerfStats() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PerfStats::BeginSystemFrame() {
|
void PerfStats::BeginSystemFrame() {
|
||||||
std::lock_guard lock{object_mutex};
|
std::scoped_lock lock{object_mutex};
|
||||||
|
|
||||||
frame_begin = Clock::now();
|
frame_begin = Clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfStats::EndSystemFrame() {
|
void PerfStats::EndSystemFrame() {
|
||||||
std::lock_guard lock{object_mutex};
|
std::scoped_lock lock{object_mutex};
|
||||||
|
|
||||||
auto frame_end = Clock::now();
|
auto frame_end = Clock::now();
|
||||||
const auto frame_time = frame_end - frame_begin;
|
const auto frame_time = frame_end - frame_begin;
|
||||||
@ -79,7 +79,7 @@ void PerfStats::EndGameFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double PerfStats::GetMeanFrametime() const {
|
double PerfStats::GetMeanFrametime() const {
|
||||||
std::lock_guard lock{object_mutex};
|
std::scoped_lock lock{object_mutex};
|
||||||
|
|
||||||
if (current_index <= IgnoreFrames) {
|
if (current_index <= IgnoreFrames) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -91,7 +91,7 @@ double PerfStats::GetMeanFrametime() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us) {
|
PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us) {
|
||||||
std::lock_guard lock{object_mutex};
|
std::scoped_lock lock{object_mutex};
|
||||||
|
|
||||||
const auto now = Clock::now();
|
const auto now = Clock::now();
|
||||||
// Walltime elapsed since stats were reset
|
// Walltime elapsed since stats were reset
|
||||||
@ -120,7 +120,7 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us
|
|||||||
}
|
}
|
||||||
|
|
||||||
double PerfStats::GetLastFrameTimeScale() const {
|
double PerfStats::GetLastFrameTimeScale() const {
|
||||||
std::lock_guard lock{object_mutex};
|
std::scoped_lock lock{object_mutex};
|
||||||
|
|
||||||
constexpr double FRAME_LENGTH = 1.0 / 60;
|
constexpr double FRAME_LENGTH = 1.0 / 60;
|
||||||
return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
|
return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
|
||||||
|
@ -80,7 +80,7 @@ bool Freezer::IsActive() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Freezer::Clear() {
|
void Freezer::Clear() {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
LOG_DEBUG(Common_Memory, "Clearing all frozen memory values.");
|
LOG_DEBUG(Common_Memory, "Clearing all frozen memory values.");
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void Freezer::Clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u64 Freezer::Freeze(VAddr address, u32 width) {
|
u64 Freezer::Freeze(VAddr address, u32 width) {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
const auto current_value = MemoryReadWidth(memory, width, address);
|
const auto current_value = MemoryReadWidth(memory, width, address);
|
||||||
entries.push_back({address, width, current_value});
|
entries.push_back({address, width, current_value});
|
||||||
@ -101,7 +101,7 @@ u64 Freezer::Freeze(VAddr address, u32 width) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Freezer::Unfreeze(VAddr address) {
|
void Freezer::Unfreeze(VAddr address) {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
LOG_DEBUG(Common_Memory, "Unfreezing memory for address={:016X}", address);
|
LOG_DEBUG(Common_Memory, "Unfreezing memory for address={:016X}", address);
|
||||||
|
|
||||||
@ -109,13 +109,13 @@ void Freezer::Unfreeze(VAddr address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Freezer::IsFrozen(VAddr address) const {
|
bool Freezer::IsFrozen(VAddr address) const {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
return FindEntry(address) != entries.cend();
|
return FindEntry(address) != entries.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Freezer::SetFrozenValue(VAddr address, u64 value) {
|
void Freezer::SetFrozenValue(VAddr address, u64 value) {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
const auto iter = FindEntry(address);
|
const auto iter = FindEntry(address);
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ void Freezer::SetFrozenValue(VAddr address, u64 value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const {
|
std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
const auto iter = FindEntry(address);
|
const auto iter = FindEntry(address);
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Freezer::Entry> Freezer::GetEntries() const {
|
std::vector<Freezer::Entry> Freezer::GetEntries() const {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ void Freezer::FrameCallback(std::uintptr_t, std::chrono::nanoseconds ns_late) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
for (const auto& entry : entries) {
|
for (const auto& entry : entries) {
|
||||||
LOG_DEBUG(Common_Memory,
|
LOG_DEBUG(Common_Memory,
|
||||||
@ -178,7 +178,7 @@ void Freezer::FrameCallback(std::uintptr_t, std::chrono::nanoseconds ns_late) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Freezer::FillEntryReads() {
|
void Freezer::FillEntryReads() {
|
||||||
std::lock_guard lock{entries_mutex};
|
std::scoped_lock lock{entries_mutex};
|
||||||
|
|
||||||
LOG_DEBUG(Common_Memory, "Updating memory freeze entries to current values.");
|
LOG_DEBUG(Common_Memory, "Updating memory freeze entries to current values.");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user