Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'actor-yield' of github.com:Takishipp/simgrid into actor-yield
[simgrid.git] / teshsuite / simix / generic_simcalls / generic_simcalls.cpp
index 1b87257..c7eb726 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
@@ -18,6 +18,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "my log messages");
 
 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)
@@ -40,7 +44,7 @@ static int master(int argc, char *argv[])
   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");
@@ -50,20 +54,19 @@ static int master(int argc, char *argv[])
 
   // 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");
@@ -73,7 +76,7 @@ static int master(int argc, char *argv[])
   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");
@@ -84,7 +87,7 @@ static int master(int argc, char *argv[])
   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");