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
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);
}
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)(); };
}
}
};
-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));
}
};
-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));
+}
}
}
{
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;
{
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);
// 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)); };
}
/**
*/
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;
}