+#include <memory>
+
+namespace simgrid::kernel::context {
+class SwappedContext;
+} // namespace simgrid::kernel::context
+
+/* Use extern "C" to make sure that this symbol is easy to recognize by name, even on exotic platforms */
+extern "C" XBT_ATTRIB_NORETURN void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context);
+
+namespace simgrid::kernel::context {
+
+class SwappedContextFactory : public ContextFactory {
+ friend SwappedContext; // Reads whether we are in parallel mode
+public:
+ SwappedContextFactory() = default;
+ SwappedContextFactory(const SwappedContextFactory&) = delete;
+ SwappedContextFactory& operator=(const SwappedContextFactory&) = delete;
+ void run_all(std::vector<actor::ActorImpl*> const& actors) override;
+
+private:
+ /* For the sequential execution */
+ unsigned long process_index_ = 0; // next actor to execute
+ SwappedContext* maestro_context_ = nullptr; // save maestro's context
+
+ /* For the parallel execution, will be created lazily with the right parameters if needed (ie, in parallel) */
+ std::unique_ptr<simgrid::xbt::Parmap<actor::ActorImpl*>> parmap_{nullptr};
+};