replace lock with lock_guard

Change-Id: I778fd472546a0287f068f04569a67315045ee901
diff --git a/src/chatroom-discovery-backend.cpp b/src/chatroom-discovery-backend.cpp
index 933a2f1..0da409d 100644
--- a/src/chatroom-discovery-backend.cpp
+++ b/src/chatroom-discovery-backend.cpp
@@ -61,14 +61,15 @@
 
     m_face->getIoService().run();
 
-    m_mutex.lock();
-    shouldResume = m_shouldResume;
-    m_shouldResume = false;
-    m_mutex.unlock();
+    {
+      std::lock_guard<std::mutex>lock(m_mutex);
+      shouldResume = m_shouldResume;
+      m_shouldResume = false;
+    }
 
   } while (shouldResume);
 
-  std::cerr << "Bye!" << std::endl;
+  std::cerr << "DiscoveryBackend: Bye!" << std::endl;
 }
 
 void
@@ -273,9 +274,10 @@
 
     updatePrefixes();
 
-    m_mutex.lock();
-    m_shouldResume = true;
-    m_mutex.unlock();
+    {
+      std::lock_guard<std::mutex>lock(m_mutex);
+      m_shouldResume = true;
+    }
 
     close();
 
@@ -403,9 +405,10 @@
   m_userDiscoveryPrefix.append(m_identity).append("CHRONOCHAT-DISCOVERYDATA");
   updatePrefixes();
 
-  m_mutex.lock();
-  m_shouldResume = true;
-  m_mutex.unlock();
+  {
+    std::lock_guard<std::mutex>lock(m_mutex);
+    m_shouldResume = true;
+  }
 
   close();
 
@@ -439,9 +442,10 @@
 void
 ChatroomDiscoveryBackend::shutdown()
 {
-  m_mutex.lock();
-  m_shouldResume = false;
-  m_mutex.unlock();
+  {
+    std::lock_guard<std::mutex>lock(m_mutex);
+    m_shouldResume = false;
+  }
 
   close();