Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #302 from mpoquet/rename-s4u-synchro-examples
[simgrid.git] / include / xbt / signal.hpp
index 08fbff6..4c1d46d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2018. 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. */
@@ -7,6 +7,7 @@
 #define SIMGRID_XBT_SIGNAL_HPP
 
 #include <functional>
+#include <utility>
 #include <vector>
 
 namespace simgrid {
@@ -26,21 +27,21 @@ namespace xbt {
     typedef std::function<R(P...)> callback_type;
     std::vector<callback_type> handlers_;
   public:
-    template<class U> XBT_ALWAYS_INLINE
+    template<class U>
     void connect(U slot)
     {
       handlers_.push_back(std::move(slot));
     }
-    XBT_ALWAYS_INLINE
     R operator()(P... args) const
     {
-      for (auto& handler : handlers_)
+      for (auto const& handler : handlers_)
         handler(args...);
     }
-    void disconnect_all_slots()
-    {
-      handlers_.clear();
-    }
+    void disconnect_slots() { handlers_.clear(); }
+    int get_slot_count() { return handlers_.size(); }
+    // deprecated
+    XBT_ATTRIB_DEPRECATED_v323("Please use xbt::disconnect_slots)") void disconnectSlots() { disconnect_slots(); }
+    XBT_ATTRIB_DEPRECATED_v323("Please use xbt::get_slot_count)") int getSlotsAmount() { return get_slot_count(); }
   };
 
 }