X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7f4f03348bd07609e258eb3b545bdafc2c881847..2376a01092173679830310f4d57b267445959f97:/src/simix/Context.cpp diff --git a/src/simix/Context.cpp b/src/simix/Context.cpp index 7115e3ab37..be5da21828 100644 --- a/src/simix/Context.cpp +++ b/src/simix/Context.cpp @@ -15,6 +15,7 @@ #include "mc/mc.h" #include +#include void SIMIX_process_set_cleanup_function( smx_process_t process, void_pfn_smxprocess_t cleanup) @@ -22,69 +23,6 @@ void SIMIX_process_set_cleanup_function( process->context->set_cleanup(cleanup); } -namespace simgrid { -namespace simix { - -class XBT_PRIVATE args { -private: - int argc_; - char** argv_; -public: - - // Main constructors - args() : argc_(0), argv_(nullptr) {} - args(int argc, char** argv) : argc_(argc), argv_(argv) {} - - // Free - void clear() - { - for (int i = 0; i < this->argc_; i++) - free(this->argv_[i]); - free(this->argv_); - this->argc_ = 0; - this->argv_ = nullptr; - } - ~args() { clear(); } - - // Copy - args(args const& that) = delete; - args& operator=(args const& that) = delete; - - // Move: - args(args&& that) : argc_(that.argc_), argv_(that.argv_) - { - that.argc_ = 0; - that.argv_ = nullptr; - } - args& operator=(args&& that) - { - this->argc_ = that.argc_; - this->argv_ = that.argv_; - that.argc_ = 0; - that.argv_ = nullptr; - return *this; - } - - int argc() const { return argc_; } - char** argv() { return argv_; } - const char*const* argv() const { return argv_; } - char* operator[](std::size_t i) { return argv_[i]; } -}; - -} -} - -static -std::function wrap_main(xbt_main_func_t code, int argc, char **argv) -{ - if (code) { - auto arg = std::make_shared(argc, argv); - return [=]() { - code(arg->argc(), arg->argv()); - }; - } else return std::function(); -} - /** * \brief creates a new context for a user level process * \param code a main function @@ -101,7 +39,7 @@ smx_context_t SIMIX_context_new( if (!simix_global) xbt_die("simix is not initialized, please call MSG_init first"); return simix_global->context_factory->create_context( - wrap_main(code, argc, argv), cleanup_func, simix_process); + simgrid::simix::wrap_main(code, argc, argv), cleanup_func, simix_process); } namespace simgrid { @@ -118,13 +56,25 @@ Context* ContextFactory::self() void ContextFactory::declare_context(void* context, std::size_t size) { -#ifdef HAVE_MC +#if HAVE_MC /* Store the address of the stack in heap to compare it apart of heap comparison */ if(MC_is_active()) MC_ignore_heap(context, size); #endif } +Context* ContextFactory::attach(void_pfn_smxprocess_t cleanup_func, smx_process_t process) +{ + xbt_die("Cannot attach with this ContextFactory.\n" + "Try using --cfg=contexts/factory:thread instead.\n"); +} + +Context* ContextFactory::create_maestro(std::function code, smx_process_t process) +{ + xbt_die("Cannot create_maestro with this ContextFactory.\n" + "Try using --cfg=contexts/factory:thread instead.\n"); +} + Context::Context(std::function code, void_pfn_smxprocess_t cleanup_func, smx_process_t process) : code_(std::move(code)), process_(process), iwannadie(false) @@ -153,5 +103,9 @@ void Context::stop() this->iwannadie = true; } +AttachContext::~AttachContext() +{ +} + +} } -} \ No newline at end of file