Using context::Context in fully qualified name was redundant.
m.attr("simgrid_version") = simgrid_version;
// Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack)
- py::object pyStopRequestEx = py::register_exception<simgrid::kernel::context::Context::StopRequest>(m, "ActorKilled");
+ py::object pyStopRequestEx = py::register_exception<simgrid::kernel::context::StopRequest>(m, "ActorKilled");
/* this_actor namespace */
void (*sleep_for_fun)(double) = &simgrid::s4u::this_actor::sleep_for; // pick the right overload
AttachContext::~AttachContext() = default;
+StopRequest::~StopRequest() = default;
+
void throw_stoprequest()
{
- throw Context::StopRequest();
+ throw StopRequest();
}
bool try_n_catch_stoprequest(std::function<void(void)> try_block)
try {
try_block();
res = true;
- } catch (Context::StopRequest const&) {
+ } catch (StopRequest const&) {
XBT_DEBUG("Caught a StopRequest");
res = false;
}
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 {
virtual void attach_stop() = 0;
};
+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(); }
+
+private:
+ std::string msg_ = std::string("Actor killed.");
+};
XBT_PUBLIC void throw_stoprequest();
XBT_PUBLIC bool try_n_catch_stoprequest(std::function<void(void)> try_block);
try {
(*context)();
context->Context::stop();
- } catch (simgrid::kernel::context::Context::StopRequest const&) {
+ } catch (simgrid::kernel::context::StopRequest const&) {
XBT_DEBUG("Caught a StopRequest");
} catch (simgrid::Exception const& e) {
XBT_INFO("Actor killed by an uncatched exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
// Forcefully kill the actor if its host is turned off. Not an HostFailureException because you should not survive that
if (actor->host_->is_off())
- actor->throw_exception(std::make_exception_ptr(simgrid::kernel::context::Context::StopRequest("host failed")));
+ actor->throw_exception(std::make_exception_ptr(simgrid::kernel::context::StopRequest("host failed")));
/* destroy the blocking synchro if any */
if (actor->waiting_synchro != nullptr) {
if (self->context_->iwannadie) {
XBT_DEBUG("Process %s@%s is dead", self->get_cname(), self->host_->get_cname());
- // throw simgrid::kernel::context::Context::StopRequest(); Does not seem to properly kill the actor
+ // throw simgrid::kernel::context::StopRequest(); Does not seem to properly kill the actor
self->context_->stop();
THROW_IMPOSSIBLE;
}
std::abort();
}
- catch (simgrid::kernel::context::Context::StopRequest& e) {
+ catch (simgrid::kernel::context::StopRequest& e) {
XBT_ERROR("Received a StopRequest at the top-level exception handler. Maybe a Java->C++ call that is not protected "
"in a try/catch?");
show_backtrace(bt);