From c7be98481986ed31b6c0cd6f1a9a88f84727f8c9 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Tue, 18 Jun 2019 10:02:38 +0200 Subject: [PATCH] sync.h uses lock_guard for mutex --- srsue/hdr/phy/sync.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/srsue/hdr/phy/sync.h b/srsue/hdr/phy/sync.h index f1f72720a..67e7876b9 100644 --- a/srsue/hdr/phy/sync.h +++ b/srsue/hdr/phy/sync.h @@ -212,20 +212,19 @@ private: * and returns the current state */ state_t run_state() { - std::unique_lock ul(inside); + std::lock_guard lg(inside); cur_state = next_state; if (state_setting) { state_setting = false; state_running = true; } cvar.notify_all(); - inside.unlock(); return cur_state; } // Called by the main thread at the end of each state to indicate it has finished. void state_exit(bool exit_ok = true) { - std::unique_lock ul(inside); + std::lock_guard lg(inside); if (cur_state == SFN_SYNC && exit_ok == true) { next_state = CAMPING; } else { @@ -235,7 +234,7 @@ private: cvar.notify_all(); } void force_sfn_sync() { - std::unique_lock ul(inside); + std::lock_guard lg(inside); next_state = SFN_SYNC; } @@ -245,23 +244,20 @@ private: * These functions are mutexed and only 1 can be called at a time */ void go_idle() { - outside.lock(); + std::lock_guard lg(outside); go_state(IDLE); - outside.unlock(); } void run_cell_search() { - outside.lock(); + std::lock_guard lg(outside); go_state(CELL_SEARCH); wait_state_run(); wait_state_next(); - outside.unlock(); } void run_sfn_sync() { - outside.lock(); + std::lock_guard lg(outside); go_state(SFN_SYNC); wait_state_run(); wait_state_next(); - outside.unlock(); }