Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
track all the useless void
[simgrid.git] / src / kernel / context / Context.cpp
index 5817bc7..d650e20 100644 (file)
 
 #include "mc/mc.h"
 
+#include "src/kernel/context/Context.hpp"
 #include "src/simix/smx_private.h"
 
-void SIMIX_process_set_cleanup_function(
-  smx_process_t process, void_pfn_smxprocess_t cleanup)
-{
-  process->context->set_cleanup(cleanup);
-}
-
 /**
  * @brief creates a new context for a user level process
  * @param code a main function
@@ -32,14 +27,14 @@ smx_context_t SIMIX_context_new(
   void_pfn_smxprocess_t cleanup_func,
   smx_process_t simix_process)
 {
-  if (!simix_global)
-    xbt_die("simix is not initialized, please call MSG_init first");
+  xbt_assert(simix_global, "simix is not initialized, please call MSG_init first");
   return simix_global->context_factory->create_context(
     std::move(code), cleanup_func, simix_process);
 }
 
 namespace simgrid {
-namespace simix {
+namespace kernel {
+namespace context {
 
 ContextFactoryInitializer factory_initializer = nullptr;
 
@@ -103,5 +98,20 @@ AttachContext::~AttachContext()
 {
 }
 
+}}}
+
+/** @brief Executes all the processes to run (in parallel if possible). */
+void SIMIX_context_runall()
+{
+  simix_global->context_factory->run_all();
 }
+
+/** @brief returns the current running context */
+smx_context_t SIMIX_context_self()
+{
+  if (simix_global && simix_global->context_factory)
+    return simix_global->context_factory->self();
+  else
+    return nullptr;
 }
+