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.
This commit is contained in:
parent
d5bcb45b2a
commit
21c71d21ae
21 changed files with 124 additions and 122 deletions
|
@ -43,7 +43,7 @@ namespace Pica {
|
|||
|
||||
void DebugContext::DoOnEvent(Event event, void* data) {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(breakpoint_mutex);
|
||||
std::unique_lock lock{breakpoint_mutex};
|
||||
|
||||
// Commit the rasterizer's caches so framebuffers, render targets, etc. will show on debug
|
||||
// widgets
|
||||
|
@ -66,7 +66,7 @@ void DebugContext::DoOnEvent(Event event, void* data) {
|
|||
|
||||
void DebugContext::Resume() {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(breakpoint_mutex);
|
||||
std::lock_guard lock{breakpoint_mutex};
|
||||
|
||||
// Tell all observers that we are about to resume
|
||||
for (auto& breakpoint_observer : breakpoint_observers) {
|
||||
|
@ -282,14 +282,14 @@ void StartPicaTracing() {
|
|||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(pica_trace_mutex);
|
||||
std::lock_guard lock(pica_trace_mutex);
|
||||
pica_trace = std::make_unique<PicaTrace>();
|
||||
|
||||
g_is_pica_tracing = true;
|
||||
}
|
||||
|
||||
void OnPicaRegWrite(PicaTrace::Write write) {
|
||||
std::lock_guard<std::mutex> lock(pica_trace_mutex);
|
||||
std::lock_guard lock(pica_trace_mutex);
|
||||
|
||||
if (!g_is_pica_tracing)
|
||||
return;
|
||||
|
@ -307,7 +307,7 @@ std::unique_ptr<PicaTrace> FinishPicaTracing() {
|
|||
g_is_pica_tracing = false;
|
||||
|
||||
// Wait until running tracing is finished
|
||||
std::lock_guard<std::mutex> lock(pica_trace_mutex);
|
||||
std::lock_guard lock(pica_trace_mutex);
|
||||
std::unique_ptr<PicaTrace> ret(std::move(pica_trace));
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -63,14 +63,14 @@ public:
|
|||
/// Constructs the object such that it observes events of the given DebugContext.
|
||||
BreakPointObserver(std::shared_ptr<DebugContext> debug_context)
|
||||
: context_weak(debug_context) {
|
||||
std::unique_lock<std::mutex> lock(debug_context->breakpoint_mutex);
|
||||
std::unique_lock lock{debug_context->breakpoint_mutex};
|
||||
debug_context->breakpoint_observers.push_back(this);
|
||||
}
|
||||
|
||||
virtual ~BreakPointObserver() {
|
||||
auto context = context_weak.lock();
|
||||
if (context) {
|
||||
std::unique_lock<std::mutex> lock(context->breakpoint_mutex);
|
||||
std::unique_lock lock(context->breakpoint_mutex);
|
||||
context->breakpoint_observers.remove(this);
|
||||
|
||||
// If we are the last observer to be destroyed, tell the debugger context that
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue