Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake_case xbt/functional.hpp
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 13 Jun 2018 21:20:16 +0000 (23:20 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 13 Jun 2018 21:20:16 +0000 (23:20 +0200)
include/simgrid/kernel/future.hpp
include/simgrid/s4u/Actor.hpp
include/xbt/functional.hpp
src/msg/msg_process.cpp
src/simix/ActorImpl.cpp
src/simix/smx_deployment.cpp
src/simix/smx_global.cpp

index e779c0a..6adfe66 100644 (file)
@@ -327,8 +327,7 @@ public:
       throw std::future_error(std::future_errc::no_state);
     // Give shared-ownership to the continuation:
     auto state = std::move(state_);
-    state->set_continuation(simgrid::xbt::makeTask(
-      std::move(continuation), state));
+    state->set_continuation(simgrid::xbt::make_task(std::move(continuation), state));
   }
 
   /** Attach a continuation to this future
@@ -347,15 +346,13 @@ public:
     Promise<R> promise;
     Future<R> future = promise.get_future();
     // ...and when the current future is ready...
-    state->set_continuation(simgrid::xbt::makeTask(
-      [](Promise<R> promise, std::shared_ptr<FutureState<T>> state, F continuation) {
-        // ...set the new future value by running the continuation.
-        Future<T> future(std::move(state));
-        simgrid::xbt::fulfillPromise(promise,[&]{
-          return continuation(std::move(future));
-        });
-      },
-      std::move(promise), state, std::move(continuation)));
+    state->set_continuation(simgrid::xbt::make_task(
+        [](Promise<R> promise, std::shared_ptr<FutureState<T>> state, F continuation) {
+          // ...set the new future value by running the continuation.
+          Future<T> future(std::move(state));
+          simgrid::xbt::fulfillPromise(promise, [&] { return continuation(std::move(future)); });
+        },
+        std::move(promise), state, std::move(continuation)));
     return std::move(future);
   }
 
index bbe2e73..e1bcbac 100644 (file)
@@ -132,8 +132,7 @@ class XBT_PUBLIC Actor : public simgrid::xbt::Extendable<Actor> {
   static std::function<void()> wrap_task(F f, Args... args)
   {
     typedef decltype(f(std::move(args)...)) R;
-    auto task = std::make_shared<simgrid::xbt::Task<R()>>(
-      simgrid::xbt::makeTask(std::move(f), std::move(args)...));
+    auto task = std::make_shared<simgrid::xbt::Task<R()>>(simgrid::xbt::make_task(std::move(f), std::move(args)...));
     return [task] { (*task)(); };
   }
 
index 1c6983a..4b5f0af 100644 (file)
@@ -52,14 +52,26 @@ public:
   }
 };
 
-template<class F> inline
-std::function<void()> wrapMain(F code, std::vector<std::string> args)
+template <class F>
+inline XBT_ATTRIB_DEPRECATED_v323("Please use wrap_main()") std::function<void()> wrapMain(
+    F code, std::vector<std::string> args)
 {
   return MainFunction<F>(std::move(code), std::move(args));
 }
 
-template<class F> inline
-std::function<void()> wrapMain(F code, int argc, const char*const argv[])
+template <class F> inline std::function<void()> wrap_main(F code, std::vector<std::string> args)
+{
+  return MainFunction<F>(std::move(code), std::move(args));
+}
+
+template <class F>
+inline XBT_ATTRIB_DEPRECATED_v323("Please use wrap_main()") std::function<void()> wrapMain(F code, int argc,
+                                                                                           const char* const argv[])
+{
+  std::vector<std::string> args(argv, argv + argc);
+  return MainFunction<F>(std::move(code), std::move(args));
+}
+template <class F> inline std::function<void()> wrap_main(F code, int argc, const char* const argv[])
 {
   std::vector<std::string> args(argv, argv + argc);
   return MainFunction<F>(std::move(code), std::move(args));
@@ -288,14 +300,19 @@ public:
   }
 };
 
-template<class F, class... Args>
-auto makeTask(F code, Args... args)
--> Task< decltype(code(std::move(args)...))() >
+template <class F, class... Args>
+XBT_ATTRIB_DEPRECATED_v323("Please use make_task()") auto makeTask(F code, Args... args)
+    -> Task<decltype(code(std::move(args)...))()>
 {
   TaskImpl<F, Args...> task(std::move(code), std::make_tuple(std::move(args)...));
   return Task<decltype(code(std::move(args)...))()>(std::move(task));
 }
 
+template <class F, class... Args> auto make_task(F code, Args... args) -> Task<decltype(code(std::move(args)...))()>
+{
+  TaskImpl<F, Args...> task(std::move(code), std::make_tuple(std::move(args)...));
+  return Task<decltype(code(std::move(args)...))()>(std::move(task));
+}
 }
 }
 
index 51ea774..521170a 100644 (file)
@@ -129,7 +129,7 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
 {
   std::function<void()> function;
   if (code)
-    function = simgrid::xbt::wrapMain(code, argc, static_cast<const char* const*>(argv));
+    function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
 
   std::unordered_map<std::string, std::string> props;
   xbt_dict_cursor_t cursor = nullptr;
index b2603b8..e45266f 100644 (file)
@@ -802,7 +802,7 @@ smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void*
 {
   if (name == nullptr)
     name = "";
-  auto wrapped_code = simgrid::xbt::wrapMain(code, argc, argv);
+  auto wrapped_code = simgrid::xbt::wrap_main(code, argc, argv);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
index 8e11f4a..79a4993 100644 (file)
@@ -58,9 +58,7 @@ void SIMIX_launch_application(const char *file)
 // Wrap a main() function into a ActorCodeFactory:
 static simgrid::simix::ActorCodeFactory toActorCodeFactory(xbt_main_func_t code)
 {
-  return [code](std::vector<std::string> args) {
-    return simgrid::xbt::wrapMain(code, std::move(args));
-  };
+  return [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); };
 }
 
 /**
index 4f05ede..9973945 100644 (file)
@@ -562,7 +562,7 @@ void SIMIX_run()
  */
 smx_timer_t SIMIX_timer_set(double date, void (*callback)(void*), void *arg)
 {
-  smx_timer_t timer = new s_smx_timer_t(date, simgrid::xbt::makeTask([callback, arg]() { callback(arg); }));
+  smx_timer_t timer = new s_smx_timer_t(date, simgrid::xbt::make_task([callback, arg]() { callback(arg); }));
   timer->handle_    = simix_timers.emplace(std::make_pair(date, timer));
   return timer;
 }