Skip to content

Commit

Permalink
Use the RAII idiom instead of calling unlock() explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
gansm committed Jun 13, 2023
1 parent a0d82f5 commit c66a8c1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions final/eventloop/timer_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ std::mutex timer_nodes_mutex{};
void onSigAlrm (int, siginfo_t* signal_info, void*)
{
const timer_t timer_id{*static_cast<const timer_t*>(signal_info->si_value.sival_ptr)};
timer_nodes_mutex.lock();
std::lock_guard<std::mutex> lock_guard(timer_nodes_mutex);

for (const auto& timer_node : timer_nodes)
{
Expand All @@ -101,8 +101,6 @@ void onSigAlrm (int, siginfo_t* signal_info, void*)

break;
}

timer_nodes_mutex.unlock();
}

} // anonymous namespace
Expand Down

0 comments on commit c66a8c1

Please sign in to comment.