Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Introduce a class mc::SimcallInspector, that allows MC to learn about the ongoing...
[simgrid.git] / include / simgrid / simix.hpp
index 2b979d7..473bb3f 100644 (file)
 #include <string>
 #include <unordered_map>
 
-XBT_PUBLIC void simcall_run_kernel(std::function<void()> const& code);
-XBT_PUBLIC void simcall_run_blocking(std::function<void()> const& code);
+XBT_PUBLIC void simcall_run_kernel(std::function<void()> const& code, simgrid::mc::SimcallInspector* t);
+XBT_PUBLIC void simcall_run_blocking(std::function<void()> const& code, simgrid::mc::SimcallInspector* t);
 
 namespace simgrid {
-namespace simix {
+namespace kernel {
+namespace actor {
 
 /** Execute some code in kernel context on behalf of the user code.
  *
@@ -41,7 +42,7 @@ namespace simix {
  * you may need to wait for that mutex to be unlocked by its current owner.
  * Potentially blocking simcall must be issued using simcall_blocking(), right below in this file.
  */
-template <class F> typename std::result_of<F()>::type simcall(F&& code)
+template <class F> typename std::result_of<F()>::type simcall(F&& code, mc::SimcallInspector* t = nullptr)
 {
   // If we are in the maestro, we take the fast path and execute the
   // code directly without simcall mashalling/unmarshalling/dispatch:
@@ -53,7 +54,7 @@ template <class F> typename std::result_of<F()>::type simcall(F&& code)
   // conveniently handles the success/failure value for us.
   typedef typename std::result_of<F()>::type R;
   simgrid::xbt::Result<R> result;
-  simcall_run_kernel([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward<F>(code)); });
+  simcall_run_kernel([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward<F>(code)); }, t);
   return result.get();
 }
 
@@ -71,7 +72,7 @@ template <class F> typename std::result_of<F()>::type simcall(F&& code)
  *
  * If your code never calls actor->simcall_answer() itself, the actor will never return from its simcall.
  */
-template <class F> typename std::result_of<F()>::type simcall_blocking(F&& code)
+template <class F> typename std::result_of<F()>::type simcall_blocking(F&& code, mc::SimcallInspector* t = nullptr)
 {
   // If we are in the maestro, we take the fast path and execute the
   // code directly without simcall mashalling/unmarshalling/dispatch:
@@ -83,9 +84,14 @@ template <class F> typename std::result_of<F()>::type simcall_blocking(F&& code)
   // conveniently handles the success/failure value for us.
   typedef typename std::result_of<F()>::type R;
   simgrid::xbt::Result<R> result;
-  simcall_run_blocking([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward<F>(code)); });
+  simcall_run_blocking([&result, &code] { simgrid::xbt::fulfill_promise(result, std::forward<F>(code)); }, t);
   return result.get();
 }
+} // namespace actor
+} // namespace kernel
+} // namespace simgrid
+namespace simgrid {
+namespace simix {
 
 XBT_ATTRIB_DEPRECATED_v325("Please manifest if you actually need this function")
     XBT_PUBLIC const std::vector<smx_actor_t>& process_get_runnable();