Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
split smx_synchro_t into a hierarchy of C++ classes
[simgrid.git] / src / simix / smx_private.hpp
index a0d704a..71504cd 100644 (file)
@@ -9,32 +9,14 @@
 
 #include <simgrid/simix.hpp>
 #include "smx_private.h"
-
-/**
- * \brief creates a new context for a user level process
- * \param code a main function
- * \param argc the number of arguments of the main function
- * \param argv the vector of arguments of the main function
- * \param cleanup_func the function to call when the context stops
- * \param cleanup_arg the argument of the cleanup_func function
- */
-static inline smx_context_t SIMIX_context_new(xbt_main_func_t code,
-                                                  int argc, char **argv,
-                                                  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");
-  return simix_global->context_factory->create_context(
-    code, argc, argv, cleanup_func, simix_process);
-}
+#include "src/simix/popping_private.h"
 
 /**
  * \brief destroy a context
  * \param context the context to destroy
  * Argument must be stopped first -- runs in maestro context
  */
-static XBT_INLINE void SIMIX_context_free(smx_context_t context)
+static inline void SIMIX_context_free(smx_context_t context)
 {
   delete context;
 }
@@ -43,7 +25,7 @@ static XBT_INLINE void SIMIX_context_free(smx_context_t context)
  * \brief stops the execution of a context
  * \param context to stop
  */
-static XBT_INLINE void SIMIX_context_stop(smx_context_t context)
+static inline void SIMIX_context_stop(smx_context_t context)
 {
   context->stop();
 }
@@ -53,7 +35,7 @@ static XBT_INLINE void SIMIX_context_stop(smx_context_t context)
         scheduled it
  \param context the context to be suspended (it must be the running one)
  */
-static XBT_INLINE void SIMIX_context_suspend(smx_context_t context)
+static inline void SIMIX_context_suspend(smx_context_t context)
 {
   context->suspend();
 }
@@ -61,7 +43,7 @@ static XBT_INLINE void SIMIX_context_suspend(smx_context_t context)
 /**
  \brief Executes all the processes to run (in parallel if possible).
  */
-static XBT_INLINE void SIMIX_context_runall(void)
+static inline void SIMIX_context_runall(void)
 {
   if (!xbt_dynar_is_empty(simix_global->process_to_run))
     simix_global->context_factory->run_all();
@@ -70,7 +52,7 @@ static XBT_INLINE void SIMIX_context_runall(void)
 /**
  \brief returns the current running context
  */
-static XBT_INLINE smx_context_t SIMIX_context_self(void)
+static inline smx_context_t SIMIX_context_self(void)
 {
   if (simix_global && simix_global->context_factory)
     return simix_global->context_factory->self();
@@ -83,7 +65,7 @@ static XBT_INLINE smx_context_t SIMIX_context_self(void)
  \param context The context
  \return The SIMIX process
  */
-static XBT_INLINE smx_process_t SIMIX_context_get_process(smx_context_t context)
+static inline smx_process_t SIMIX_context_get_process(smx_context_t context)
 {
   return context->process();
 }
@@ -96,6 +78,15 @@ XBT_PRIVATE ContextFactory* sysv_factory();
 XBT_PRIVATE ContextFactory* raw_factory();
 XBT_PRIVATE ContextFactory* boost_factory();
 
+template<class R, class... Args> inline
+R simcall(e_smx_simcall_t call, Args&&... args)
+{
+  smx_process_t self = SIMIX_process_self();
+  marshal(&self->simcall, call, std::forward<Args>(args)...);
+  simcall_call(self);
+  return unmarshal<R>(self->simcall.result);
+}
+
 }
 }