X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7f4f03348bd07609e258eb3b545bdafc2c881847..b22d6b4f77d1ae6f88279b887de6b7451d1e6626:/src/simix/smx_private.hpp diff --git a/src/simix/smx_private.hpp b/src/simix/smx_private.hpp index a6051cc82c..f114e5ffef 100644 --- a/src/simix/smx_private.hpp +++ b/src/simix/smx_private.hpp @@ -1,83 +1,48 @@ -/* Copyright (c) 2007-2010, 2012-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef SIMGRID_SIMIX_PRIVATE_HPP -#define SIMGRID_SIMIX_PRIVATE_HPP +#ifndef SIMIX_PRIVATE_HPP +#define SIMIX_PRIVATE_HPP -#include -#include "smx_private.h" +#include "simgrid/s4u/Actor.hpp" +#include "src/kernel/actor/ActorImpl.hpp" +#include "src/kernel/context/Context.hpp" -/** - * \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) -{ - delete context; -} +/********************************** Simix Global ******************************/ -/** - * \brief stops the execution of a context - * \param context to stop - */ -static XBT_INLINE void SIMIX_context_stop(smx_context_t context) -{ - context->stop(); -} +namespace simgrid { +namespace simix { -/** - \brief suspends a context and return the control back to the one which - 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) -{ - context->suspend(); -} +class Global { + kernel::context::ContextFactory* context_factory_ = nullptr; + kernel::actor::ActorImpl* maestro_ = nullptr; -/** - \brief Executes all the processes to run (in parallel if possible). - */ -static XBT_INLINE void SIMIX_context_runall(void) -{ - if (!xbt_dynar_is_empty(simix_global->process_to_run)) - simix_global->context_factory->run_all(); -} +public: + bool is_maestro(const kernel::actor::ActorImpl* actor) const { return actor == maestro_; } + void set_maestro(kernel::actor::ActorImpl* actor) { maestro_ = actor; } + kernel::actor::ActorImpl* get_maestro() const { return maestro_; } + void destroy_maestro() + { + delete maestro_; + maestro_ = nullptr; + } -/** - \brief returns the current running context - */ -static XBT_INLINE smx_context_t SIMIX_context_self(void) -{ - if (simix_global && simix_global->context_factory) - return simix_global->context_factory->self(); - else - return nullptr; + kernel::context::ContextFactory* get_context_factory() const { return context_factory_; } + void set_context_factory(kernel::context::ContextFactory* factory) { context_factory_ = factory; } + bool has_context_factory() const { return context_factory_ != nullptr; } + void destroy_context_factory() + { + delete context_factory_; + context_factory_ = nullptr; + } +}; } - -/** - \brief returns the SIMIX process associated to a context - \param context The context - \return The SIMIX process - */ -static XBT_INLINE smx_process_t SIMIX_context_get_process(smx_context_t context) -{ - return context->process(); } -namespace simgrid { -namespace simix { - -XBT_PRIVATE ContextFactory* thread_factory(); -XBT_PRIVATE ContextFactory* sysv_factory(); -XBT_PRIVATE ContextFactory* raw_factory(); -XBT_PRIVATE ContextFactory* boost_factory(); +XBT_PUBLIC_DATA std::unique_ptr simix_global; -} -} +XBT_PUBLIC void SIMIX_clean(); #endif