-/* Copyright (c) 2016-2017. The SimGrid Team.
+/* Copyright (c) 2016-2018. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <simgrid/simix.h>
#include <simgrid/simix.hpp>
-XBT_PUBLIC(void) simcall_run_blocking(std::function<void()> const& code);
+XBT_PUBLIC void simcall_run_blocking(std::function<void()> const& code);
namespace simgrid {
namespace simix {
-XBT_PUBLIC(void) unblock(smx_actor_t process);
+XBT_PUBLIC void unblock(smx_actor_t process);
/** Execute some code in kernel mode and wakes up the actor when
* the result is available.
simcall_run_blocking([&result, self, &code]{
try {
auto future = code();
- future.then_([&result, self](simgrid::kernel::Future<T> value) {
- simgrid::xbt::setPromise(result, value);
+ future.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
+ simgrid::xbt::setPromise(result, simgrid::kernel::Future<T>(value));
simgrid::simix::unblock(self);
});
}
class Future {
public:
Future() { /* Nothing to do*/}
- Future(simgrid::kernel::Future<T> future) : future_(std::move(future)) {}
+ explicit Future(simgrid::kernel::Future<T> future) : future_(std::move(future)) {}
bool valid() const { return future_.valid(); }
T get()
simcall_run_blocking([this, &result, self]{
try {
// When the kernel future is ready...
- this->future_.then_([&result, self](simgrid::kernel::Future<T> value) {
+ this->future_.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
// ... wake up the process with the result of the kernel future.
- simgrid::xbt::setPromise(result, value);
+ simgrid::xbt::setPromise(result, simgrid::kernel::Future<T>(value));
simgrid::simix::unblock(self);
});
}
simcall_run_blocking([this, &exception, self]{
try {
// When the kernel future is ready...
- this->future_.then_([this, self](simgrid::kernel::Future<T> value) {
+ this->future_.then_([this, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
// ...store it the simix kernel and wake up.
- this->future_ = std::move(value);
+ this->future_ = std::move(simgrid::kernel::Future<T>(value));
simgrid::simix::unblock(self);
});
}
typedef decltype(code().get()) T;
// Execute the code in the kernel and get the kernel future:
- simgrid::kernel::Future<T> future =
- simgrid::simix::kernelImmediate(std::move(code));
+ simgrid::kernel::Future<T> future = simgrid::simix::simcall(std::move(code));
// Wrap the kernel future in a actor future:
return simgrid::simix::Future<T>(std::move(future));