]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#890] addressed review
authorRazvan Becheriu <razvan@isc.org>
Wed, 29 Jan 2020 13:39:59 +0000 (15:39 +0200)
committerRazvan Becheriu <razvan@isc.org>
Wed, 29 Jan 2020 13:39:59 +0000 (15:39 +0200)
src/lib/dhcpsrv/alloc_engine.h
src/lib/util/multi_threading_mgr.h

index 3fed7e0564a0557d381d77ffc48fa415198d7f1c..d75907eb3fd72cfd112ef9d11ad5a123f1bfce60 100644 (file)
@@ -98,8 +98,11 @@ protected:
                     const ClientClasses& client_classes,
                     const DuidPtr& duid,
                     const isc::asiolink::IOAddress& hint) {
-            return util::MultiThreadingMgr::call(
-                mutex_, [&]() {return pickAddressInternal(subnet, client_classes, duid, hint);});
+            if (MultiThreadingMgr::instance().getMode()) {
+                return pickAddressInternal(subnet, client_classes, duid, hint);
+            } else {
+                return pickAddressInternal(subnet, client_classes, duid, hint);
+            }
         }
 
         /// @brief Default constructor.
index 1b2f7681106d84a8a6f6e712400b21eb8525c278..abaa7ae66727b66b173d9d2f0bfffdaf7c0744ef 100644 (file)
@@ -8,7 +8,6 @@
 #define MULTI_THREADING_MGR_H
 
 #include <boost/noncopyable.hpp>
-#include <mutex>
 
 namespace isc {
 namespace util {
@@ -29,14 +28,18 @@ namespace util {
 /// For instance for a class protected by its mutex:
 /// @code
 /// namespace locked {
-///     int foo() { ... }
+///     void foo() { ... }
 /// } // end of locked namespace
 ///
-/// int foo() {
-///     return MultiThreadingMgr::call(mutex_, []() {return locked::foo()});
+/// void foo() {
+///     if (MultiThreadingMgr::instance().getMode()) {
+///         lock_guard<mutex> lock(mutex_);
+///         locked::foo();
+///     } else {
+///         locked::foo();
+///     }
 /// }
 /// @endcode
-
 class MultiThreadingMgr : public boost::noncopyable {
 public:
 
@@ -59,23 +62,6 @@ public:
     /// @param enabled The new mode.
     void setMode(bool enabled);
 
-    /// @brief Call a Functor in MT or ST mode
-    ///
-    /// @tparam Lockable a lock which is used to create a thread safe context
-    /// @tparam Callable a functor which will be called in MT or ST mode
-    /// @param lk the lock object to perform lock in MT mode
-    /// @param f the functor to call
-    /// @result the result of the functor call
-    template<typename Lockable, typename Callable>
-    static auto call(Lockable& lk, const Callable& f) -> decltype(f()) {
-        if (MultiThreadingMgr::instance().getMode()) {
-            std::lock_guard<Lockable> lock(lk);
-            return f();
-        } else {
-            return f();
-        }
-    }
-
 protected:
 
     /// @brief Constructor.