X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0f48c2d922a965695be62f682811459b901f01ea..2d37e348a09783cda723c7019640ee69de168324:/src/kernel/context/Context.hpp diff --git a/src/kernel/context/Context.hpp b/src/kernel/context/Context.hpp index f60a6cdc5b..1cf7104473 100644 --- a/src/kernel/context/Context.hpp +++ b/src/kernel/context/Context.hpp @@ -72,21 +72,6 @@ public: static Context* self(); /** @brief Sets the current context of this thread */ static void set_current(Context* self); - - class StopRequest { - /** @brief Exception launched to kill a process, in order to properly unwind its stack and release RAII stuff - * - * Nope, Sonar, this should not inherit of std::exception nor of simgrid::Exception. - * Otherwise, users may accidentally catch it with a try {} catch (std::exception) - */ - public: - StopRequest() = default; - explicit StopRequest(std::string msg) : msg_(std::string("Actor killed (") + msg + std::string(").")) {} - const char* what() const noexcept { return msg_.c_str(); } - - private: - std::string msg_ = std::string("Actor killed."); - }; }; class XBT_PUBLIC AttachContext : public Context { @@ -107,8 +92,24 @@ public: virtual void attach_stop() = 0; }; -XBT_PUBLIC void throw_stoprequest(); -XBT_PUBLIC bool try_n_catch_stoprequest(std::function try_block, std::function catch_block); +class XBT_PUBLIC StopRequest { + /** @brief Exception launched to kill a process, in order to properly unwind its stack and release RAII stuff + * + * Nope, Sonar, this should not inherit of std::exception nor of simgrid::Exception. + * Otherwise, users may accidentally catch it with a try {} catch (std::exception) + */ +public: + StopRequest() = default; + explicit StopRequest(std::string msg) : msg_(std::string("Actor killed (") + msg + std::string(").")) {} + ~StopRequest(); + const char* what() const noexcept { return msg_.c_str(); } + + static void do_throw(); + static bool try_n_catch(std::function try_block); + +private: + std::string msg_ = std::string("Actor killed."); +}; /* This allows Java to hijack the context factory (Java induces factories of factory :) */ typedef ContextFactory* (*ContextFactoryInitializer)();