-/* Copyright (c) 2016. The SimGrid Team.
+/* Copyright (c) 2016-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
namespace example {
+class exception : public std::runtime_error {
+ using std::runtime_error::runtime_error;
+};
+
/** Create a future which becomes ready when the date is reached */
static
simgrid::kernel::Future<void> kernel_wait_until(double date)
XBT_INFO("kernel, returned");
// Synchronize on a successful Future<void>:
- simgrid::simix::kernelSync([&] {
+ simgrid::simix::kernelSync([] {
return kernel_wait_until(10).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelSync with void");
// Synchronize on a failing Future<void>:
try {
- simgrid::simix::kernelSync([&] {
+ simgrid::simix::kernelSync([] {
return kernel_wait_until(20).then([](simgrid::kernel::Future<void> future) {
future.get();
- throw std::runtime_error("Exception throwed from kernel_defer");
+ throw example::exception("Exception throwed from kernel_defer");
});
});
XBT_ERROR("No exception caught!");
- }
- catch(std::runtime_error& e) {
+ } catch (const example::exception& e) {
XBT_INFO("Exception caught: %s", e.what());
}
// Synchronize on a successul Future<int> and get the value:
- int res = simgrid::simix::kernelSync([&] {
+ int res = simgrid::simix::kernelSync([] {
return kernel_wait_until(30).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelSync with value");
XBT_INFO("kernelSync with value returned with %i", res);
// Synchronize on a successul Future<int> and get the value:
- simgrid::simix::Future<int> future = simgrid::simix::kernelAsync([&] {
+ simgrid::simix::Future<int> future = simgrid::simix::kernelAsync([] {
return kernel_wait_until(50).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelAsync with value");
XBT_INFO("kernelAsync with value returned with %i", res);
// Synchronize on a successul Future<int> and get the value:
- future = simgrid::simix::kernelAsync([&] {
+ future = simgrid::simix::kernelAsync([] {
return kernel_wait_until(60).then([](simgrid::kernel::Future<void> future) {
future.get();
XBT_INFO("kernelAsync with value");