Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake_case simix/blocking_simcall.hpp
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 16 Jun 2018 21:26:32 +0000 (23:26 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 16 Jun 2018 21:26:32 +0000 (23:26 +0200)
doc/doxygen/inside_extending.doc
doc/doxygen/uhood_switch.doc
include/simgrid/simix/blocking_simcall.hpp
teshsuite/simix/generic-simcalls/generic-simcalls.cpp
teshsuite/simix/generic-simcalls/generic-simcalls.tesh

index e13c61c..a1f1286 100644 (file)
@@ -201,7 +201,7 @@ If there is no blocking and no mutation involved (getters), you might consider
 avoiding switching to Maestro and reading directly the data you're interested
 in.
 
-For simcalls which might block, `kernelSync()` can be used. It takes a
+For simcalls which might block, `kernel_sync()` can be used. It takes a
 C++ callback and executes it immediately in maestro. This C++ callback is
 expected to return a `simgrid::kernel::Future<T>` reprensenting the operation
 in the kernal. When the operations completes, the user process is waken up
@@ -209,25 +209,25 @@ with the result:
 
 ~~~
 try {
-  std::vector<char> result = simgrid::simix::kernelSync([&] {
+  std::vector<char> result = simgrid::simix::kernel_sync([&] {
     // Fictional example, simgrid::kernel::readFile does not exist.
     simgrid::kernel::Future<std::vector<char>> result = simgrid::kernel::readFile(file);
     return result;
   });
   XBT_DEBUG("Finished reading file %s: length %zu", file, result.size());
 }
-// If the operation failed, kernelSync() throws an exception:
+// If the operation failed, kernel_sync() throws an exception:
 catch (std::runtime_error& e) {
   XBT_ERROR("Could not read file %s", file);
 }
 ~~~
 
-Asynchronous blocks can be implemented with `kernelAsync()`. It works
-like `kernelSync()` but does not block. Instead, it returns a
+Asynchronous blocks can be implemented with `kernel_async()`. It works
+like `kernel_sync()` but does not block. Instead, it returns a
 `simgrid::simix::Future` representing the operation in the process:
 
 ~~~
-simgrid::simix::Future<std:vector<char>> result = simgrid::simix::kernelSync([&] {
+simgrid::simix::Future<std:vector<char>> result = simgrid::simix::kernel_sync([&] {
   // Fictional example, simgrid::kernel::readFile does not exist.
   simgrid::kernek::Future<std::vector<char>> result = simgrid::kernel::readFile(file);
   return result;
@@ -249,7 +249,7 @@ catch (std::runtime_error& e) {
 }
 ~~~
 
-<b>Note:</b> `kernelSync(f)` could be implemented as `kernelAsync(f).get()`.
+<b>Note:</b> `kernel_sync(f)` could be implemented as `kernel_async(f).get()`.
 
 \section simgrid_dev_guide_tag What is How to add a new tag for xml files?
 
index ac1b6fa..7247341 100644 (file)
@@ -468,14 +468,14 @@ kernel which will wake up the actor (with
 `simgrid::simix::unblock(actor)`) when the operation is completed.
 
 This is wrapped in a higher-level primitive as well. The
-`kernelSync()` function expects a function-object which is executed
+`kernel_sync()` function expects a function-object which is executed
 immediately in the simulation kernel and returns a `Future<T>`.  The
 simulator blocks the actor and resumes it when the `Future<T>` becomes
 ready with its result:
 
 @code{cpp}
 template<class F>
-auto kernelSync(F code) -> decltype(code().get())
+auto kernel_sync(F code) -> decltype(code().get())
 {
   typedef decltype(code().get()) T;
   if (SIMIX_is_maestro())
@@ -510,7 +510,7 @@ auto kernelSync(F code) -> decltype(code().get())
 A contrived example of this would be:
 
 @code{cpp}
-int res = simgrid::simix::kernelSync([&] {
+int res = simgrid::simix::kernel_sync([&] {
   return kernel_wait_until(30).then(
     [](simgrid::kernel::Future<void> future) {
       return 42;
@@ -521,7 +521,7 @@ int res = simgrid::simix::kernelSync([&] {
 
 ### Asynchronous operations {#uhood_switch_v2_async}
 
-We can write the related `kernelAsync()` which wakes up the actor immediately
+We can write the related `kernel_async()` which wakes up the actor immediately
 and returns a future to the actor. As this future is used in the actor context,
 it is a different future
 (`simgrid::simix::Future` instead of `simgrid::kernel::Future`)
@@ -572,12 +572,12 @@ T simgrid::simix::Future<T>::get()
 }
 @endcode
 
-`kernelAsync()` simply :wink: calls `kernelImmediate()` and wraps the
+`kernel_async()` simply :wink: calls `kernelImmediate()` and wraps the
 `simgrid::kernel::Future` into a `simgrid::simix::Future`:
 
 @code{cpp}
 template<class F>
-auto kernelAsync(F code)
+auto kernel_async(F code)
   -> Future<decltype(code().get())>
 {
   typedef decltype(code().get()) T;
@@ -594,7 +594,7 @@ auto kernelAsync(F code)
 A contrived example of this would be:
 
 @code{cpp}
-simgrid::simix::Future<int> future = simgrid::simix::kernelSync([&] {
+simgrid::simix::Future<int> future = simgrid::simix::kernel_sync([&] {
   return kernel_wait_until(30).then(
     [](simgrid::kernel::Future<void> future) {
       return 42;
@@ -605,18 +605,18 @@ do_some_stuff();
 int res = future.get();
 @endcode
 
-`kernelSync()` could be rewritten as:
+`kernel_sync()` could be rewritten as:
 
 @code{cpp}
 template<class F>
-auto kernelSync(F code) -> decltype(code().get())
+auto kernel_sync(F code) -> decltype(code().get())
 {
-  return kernelAsync(std::move(code)).get();
+  return kernel_async(std::move(code)).get();
 }
 @endcode
 
 The semantic is equivalent but this form would require two simcalls
-instead of one to do the same job (one in `kernelAsync()` and one in
+instead of one to do the same job (one in `kernel_async()` and one in
 `.get()`).
 
 ## Mutexes and condition variables
@@ -769,7 +769,7 @@ We wrote two future implementations based on the `std::future` API:
 * the second one is a wait-based (`future.get()`) future used in the actors
   which waits using a simcall.
 
-These futures are used to implement `kernelSync()` and `kernelAsync()` which
+These futures are used to implement `kernel_sync()` and `kernel_async()` which
 expose asynchronous operations in the simulation kernel to the actors.
 
 In addition, we wrote variations of some other C++ standard library
index 2a93bf2..d2c87da 100644 (file)
@@ -46,8 +46,7 @@ XBT_PUBLIC void unblock(smx_actor_t process);
  * @return         Value of the kernel future
  * @exception      Exception from the kernel future
  */
-template<class F>
-auto kernelSync(F code) -> decltype(code().get())
+template <class F> auto kernel_sync(F code) -> decltype(code().get())
 {
   typedef decltype(code().get()) T;
   if (SIMIX_is_maestro())
@@ -71,6 +70,11 @@ auto kernelSync(F code) -> decltype(code().get())
   });
   return result.get();
 }
+template <class F>
+XBT_ATTRIB_DEPRECATED_v323("Please use simix::kernel_sync()") auto kernelSync(F code) -> decltype(code().get())
+{
+  return kernel_sync(code);
+}
 
 /** A blocking (`wait()`-based) future for SIMIX processes */
 // TODO, .wait_for()
@@ -146,9 +150,7 @@ private:
  *  @param code SimGrid kernel code which returns a simgrid::kernel::Future
  *  @return     Actor future
  */
-template<class F>
-auto kernelAsync(F code)
-  -> Future<decltype(code().get())>
+template <class F> auto kernel_async(F code) -> Future<decltype(code().get())>
 {
   typedef decltype(code().get()) T;
 
@@ -158,7 +160,11 @@ auto kernelAsync(F code)
   // Wrap the kernel future in a actor future:
   return simgrid::simix::Future<T>(std::move(future));
 }
-
+template <class F>
+XBT_ATTRIB_DEPRECATED_v323("Please use simix::kernel_sync()") auto kernelAsync(F code) -> Future<decltype(code().get())>
+{
+  return kernel_async(code);
+}
 }
 }
 
index 8e9ffc4..497861e 100644 (file)
@@ -38,17 +38,17 @@ static int master(int argc, char* argv[])
   XBT_INFO("kernel, returned");
 
   // Synchronize on a successful Future<void>:
-  simgrid::simix::kernelSync([] {
+  simgrid::simix::kernel_sync([] {
     return kernel_wait_until(10).then([](simgrid::kernel::Future<void> future) {
       future.get();
-      XBT_INFO("kernelSync with void");
+      XBT_INFO("kernel_sync with void");
     });
   });
-  XBT_INFO("kernelSync with void, returned");
+  XBT_INFO("kernel_sync with void, returned");
 
   // Synchronize on a failing Future<void>:
   try {
-    simgrid::simix::kernelSync([] {
+    simgrid::simix::kernel_sync([] {
       return kernel_wait_until(20).then([](simgrid::kernel::Future<void> future) {
         future.get();
         throw example::exception("Exception throwed from kernel_defer");
@@ -60,31 +60,31 @@ static int master(int argc, char* argv[])
   }
 
   // Synchronize on a successul Future<int> and get the value:
-  int res = simgrid::simix::kernelSync([] {
+  int res = simgrid::simix::kernel_sync([] {
     return kernel_wait_until(30).then([](simgrid::kernel::Future<void> future) {
       future.get();
-      XBT_INFO("kernelSync with value");
+      XBT_INFO("kernel_sync with value");
       return 42;
     });
   });
-  XBT_INFO("kernelSync with value returned with %i", res);
+  XBT_INFO("kernel_sync 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::kernel_async([] {
     return kernel_wait_until(50).then([](simgrid::kernel::Future<void> future) {
       future.get();
-      XBT_INFO("kernelAsync with value");
+      XBT_INFO("kernel_async with value");
       return 43;
     });
   });
   res = future.get();
-  XBT_INFO("kernelAsync with value returned with %i", res);
+  XBT_INFO("kernel_async with value returned with %i", res);
 
   // Synchronize on a successul Future<int> and get the value:
-  future = simgrid::simix::kernelAsync([] {
+  future = simgrid::simix::kernel_async([] {
     return kernel_wait_until(60).then([](simgrid::kernel::Future<void> future) {
       future.get();
-      XBT_INFO("kernelAsync with value");
+      XBT_INFO("kernel_async with value");
       return 43;
     });
   });
@@ -92,7 +92,7 @@ static int master(int argc, char* argv[])
   future.wait();
   XBT_INFO("The future is %s", future.is_ready() ? "ready" : "not ready");
   res = future.get();
-  XBT_INFO("kernelAsync with value returned with %i", res);
+  XBT_INFO("kernel_async with value returned with %i", res);
 
   return 0;
 }
index f168c68..0cbed1d 100644 (file)
@@ -2,14 +2,14 @@ $ ${bindir:=.}/generic-simcalls --cfg=contexts/stack-size:96 ${srcdir:=.}/exampl
 > [Tremblay:master:(1) 0.000000] [test/INFO] Start
 > [0.000000] [test/INFO] kernel
 > [Tremblay:master:(1) 0.000000] [test/INFO] kernel, returned
-> [10.000000] [test/INFO] kernelSync with void
-> [Tremblay:master:(1) 10.000000] [test/INFO] kernelSync with void, returned
+> [10.000000] [test/INFO] kernel_sync with void
+> [Tremblay:master:(1) 10.000000] [test/INFO] kernel_sync with void, returned
 > [Tremblay:master:(1) 20.000000] [test/INFO] Exception caught: Exception throwed from kernel_defer
-> [30.000000] [test/INFO] kernelSync with value
-> [Tremblay:master:(1) 30.000000] [test/INFO] kernelSync with value returned with 42
-> [50.000000] [test/INFO] kernelAsync with value
-> [Tremblay:master:(1) 50.000000] [test/INFO] kernelAsync with value returned with 43
+> [30.000000] [test/INFO] kernel_sync with value
+> [Tremblay:master:(1) 30.000000] [test/INFO] kernel_sync with value returned with 42
+> [50.000000] [test/INFO] kernel_async with value
+> [Tremblay:master:(1) 50.000000] [test/INFO] kernel_async with value returned with 43
 > [Tremblay:master:(1) 50.000000] [test/INFO] The future is not ready
-> [60.000000] [test/INFO] kernelAsync with value
+> [60.000000] [test/INFO] kernel_async with value
 > [Tremblay:master:(1) 60.000000] [test/INFO] The future is ready
-> [Tremblay:master:(1) 60.000000] [test/INFO] kernelAsync with value returned with 43
\ No newline at end of file
+> [Tremblay:master:(1) 60.000000] [test/INFO] kernel_async with value returned with 43
\ No newline at end of file