-/* Copyright (c) 2016-2018. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2019. 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. */
{
auto promise = std::make_shared<simgrid::kernel::Promise<void>>();
auto future = promise->get_future();
- SIMIX_timer_set(date, [promise] { promise->set_value(); });
+ simgrid::simix::Timer::set(date, [promise] { promise->set_value(); });
return future;
}
// Synchronize on a successful Future<void>:
simgrid::simix::kernel_sync([] {
- return kernel_wait_until(10).then([](simgrid::kernel::Future<void> future) {
- future.get();
+ return kernel_wait_until(10).then([](simgrid::kernel::Future<void> f) {
+ f.get();
XBT_INFO("kernel_sync with void");
});
});
// Synchronize on a failing Future<void>:
try {
simgrid::simix::kernel_sync([] {
- return kernel_wait_until(20).then([](simgrid::kernel::Future<void> future) {
- future.get();
+ return kernel_wait_until(20).then([](simgrid::kernel::Future<void> f) {
+ f.get();
throw example::exception("Exception throwed from kernel_defer");
});
});
// Synchronize on a successul Future<int> and get the value:
int res = simgrid::simix::kernel_sync([] {
- return kernel_wait_until(30).then([](simgrid::kernel::Future<void> future) {
- future.get();
+ return kernel_wait_until(30).then([](simgrid::kernel::Future<void> f) {
+ f.get();
XBT_INFO("kernel_sync with value");
return 42;
});
// Synchronize on a successul Future<int> and get the value:
simgrid::simix::Future<int> future = simgrid::simix::kernel_async([] {
- return kernel_wait_until(50).then([](simgrid::kernel::Future<void> future) {
- future.get();
+ return kernel_wait_until(50).then([](simgrid::kernel::Future<void> f) {
+ f.get();
XBT_INFO("kernel_async with value");
return 43;
});
// Synchronize on a successul Future<int> and get the value:
future = simgrid::simix::kernel_async([] {
- return kernel_wait_until(60).then([](simgrid::kernel::Future<void> future) {
- future.get();
+ return kernel_wait_until(60).then([](simgrid::kernel::Future<void> f) {
+ f.get();
XBT_INFO("kernel_async with value");
return 43;
});