Rationale: exceptions sometimes fail to pass correctly between shared
libraries, specially on FreeBSD or OS X.
AttachContext::~AttachContext() = default;
+void throw_stoprequest()
+{
+ throw Context::StopRequest();
+}
+
+bool try_n_catch_stoprequest(std::function<void(void)> try_block, std::function<void(void)> catch_block)
+{
+ bool res;
+ try {
+ try_block();
+ res = true;
+ } catch (Context::StopRequest const&) {
+ XBT_DEBUG("Caught a StopRequest");
+ catch_block();
+ res = false;
+ }
+ return res;
+}
}}}
/** @brief Executes all the processes to run (in parallel if possible). */
#include "src/kernel/activity/ActivityImpl.hpp"
#include <csignal>
+#include <functional>
/* Process creation/destruction callbacks */
typedef void (*void_pfn_smxprocess_t)(smx_actor_t);
virtual void attach_stop() = 0;
};
+XBT_PUBLIC void throw_stoprequest();
+XBT_PUBLIC bool try_n_catch_stoprequest(std::function<void(void)> try_block, std::function<void(void)> catch_block);
+
/* This allows Java to hijack the context factory (Java induces factories of factory :) */
typedef ContextFactory* (*ContextFactoryInitializer)();
XBT_PUBLIC_DATA ContextFactoryInitializer factory_initializer;