Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rely on template argument deduction (sonar, c++17).
[simgrid.git] / src / xbt / OsSemaphore.hpp
index 6459850..b29a665 100644 (file)
@@ -1,8 +1,10 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <xbt/base.h>
+
 #include <condition_variable>
 #include <mutex>
 
@@ -10,18 +12,18 @@ namespace simgrid {
 namespace xbt {
 class XBT_PUBLIC OsSemaphore {
 public:
-  inline OsSemaphore(unsigned int uiCount) : capa_(uiCount) {}
+  explicit inline OsSemaphore(unsigned int capa) : capa_(capa) {}
 
   inline void acquire()
   {
-    std::unique_lock<std::mutex> lock(mutex_);
-    condition_.wait(lock, [&]() -> bool { return capa_ > 0; });
+    std::unique_lock lock(mutex_);
+    condition_.wait(lock, [this]() { return capa_ > 0; });
     --capa_;
   }
 
   inline void release()
   {
-    std::unique_lock<std::mutex> lock(mutex_);
+    std::unique_lock lock(mutex_);
     ++capa_;
     condition_.notify_one();
   }