Skip to content

Commit 7f227b2

Browse files
committed
*: use std::lock_guard instead of std::scoped_lock
std::lock_guard is a simpler template for locking just one mutex, while std::scoped_lock is more complex because it allows locking multiple mutexes, avoiding deadlocks. This isn't what we need, so let's use the simpler one.
1 parent 8a25b3d commit 7f227b2

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/event/Loop.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ EventLoop::Run() noexcept
498498
/* try to handle DeferEvents without WakeFD
499499
overhead */
500500
{
501-
const std::scoped_lock lock{mutex};
501+
const std::lock_guard lock{mutex};
502502
HandleInject();
503503
#endif
504504

@@ -526,7 +526,7 @@ EventLoop::Run() noexcept
526526

527527
#ifdef HAVE_THREADED_EVENT_LOOP
528528
{
529-
const std::scoped_lock lock{mutex};
529+
const std::lock_guard lock{mutex};
530530
busy = true;
531531
}
532532
#endif
@@ -558,7 +558,7 @@ EventLoop::AddInject(InjectEvent &d) noexcept
558558
bool must_wake;
559559

560560
{
561-
const std::scoped_lock lock{mutex};
561+
const std::lock_guard lock{mutex};
562562
if (d.IsPending())
563563
return;
564564

@@ -577,7 +577,7 @@ EventLoop::AddInject(InjectEvent &d) noexcept
577577
void
578578
EventLoop::RemoveInject(InjectEvent &d) noexcept
579579
{
580-
const std::scoped_lock protect{mutex};
580+
const std::lock_guard protect{mutex};
581581

582582
if (d.IsPending())
583583
inject.erase(inject.iterator_to(d));
@@ -605,7 +605,7 @@ EventLoop::OnWake() noexcept
605605
return;
606606
}
607607

608-
const std::scoped_lock lock{mutex};
608+
const std::lock_guard lock{mutex};
609609
HandleInject();
610610
}
611611

src/event/Loop.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public:
244244
*/
245245
void InjectBreak() noexcept {
246246
{
247-
const std::scoped_lock lock{mutex};
247+
const std::lock_guard lock{mutex};
248248
quit_injected = true;
249249
}
250250

0 commit comments

Comments
 (0)