namespace context {
// BoostContextFactory
-
-BoostContextFactory::BoostContextFactory() : SwappedContextFactory("BoostContextFactory") {}
-
-BoostContextFactory::~BoostContextFactory() = default;
-
smx_context_t BoostContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func,
smx_actor_t process)
{
#endif
}
-void BoostContext::stop()
-{
- Context::stop();
- throw StopRequest();
-}
-
// ParallelBoostContext
void ParallelBoostContext::suspend()
{
BoostContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process,
SwappedContextFactory* factory);
~BoostContext() override;
- void stop() override;
void swap_into(SwappedContext* to) override;
class BoostContextFactory : public SwappedContextFactory {
public:
- BoostContextFactory();
- ~BoostContextFactory() override;
+ BoostContextFactory() : SwappedContextFactory("BoostContextFactory") {}
+
Context* create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
};
}}} // namespace
// RawContextFactory
-RawContextFactory::RawContextFactory() : SwappedContextFactory("RawContextFactory") {}
-
-RawContextFactory::~RawContextFactory() = default;
-
Context* RawContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func,
smx_actor_t process)
{
ASAN_FINISH_SWITCH(fake_stack, &from->asan_ctx_->asan_stack_, &from->asan_ctx_->asan_stack_size_);
}
-void RawContext::stop()
-{
- Context::stop();
- throw StopRequest();
-}
-
// ParallelRawContext
-void ParallelRawContext::run_all()
-{
- threads_working_ = 0;
- if (parmap_ == nullptr)
- parmap_ = new simgrid::xbt::Parmap<smx_actor_t>(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode());
- parmap_->apply(
- [](smx_actor_t process) {
- ParallelRawContext* context = static_cast<ParallelRawContext*>(process->context_);
- context->resume();
- },
- simix_global->process_to_run);
-}
-
void ParallelRawContext::suspend()
{
/* determine the next context */
RawContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process,
SwappedContextFactory* factory);
~RawContext() override;
- void stop() override;
void swap_into(SwappedContext* to) override;
}
void suspend() override;
void resume() override;
-
- static void run_all();
};
class RawContextFactory : public SwappedContextFactory {
public:
- RawContextFactory();
- ~RawContextFactory() override;
+ RawContextFactory() : SwappedContextFactory("RawContextFactory") {}
+
Context* create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
};
}}} // namespace
}
}
+void SwappedContext::stop()
+{
+ Context::stop();
+ throw StopRequest();
+}
+
} // namespace context
} // namespace kernel
} // namespace simgrid
static void initialize(bool parallel); // Initialize the module, using the options
static void finalize(); // Finalize the module
- virtual void suspend();
+ void suspend() override;
virtual void resume();
+ void stop() override;
virtual void swap_into(SwappedContext* to) = 0; // Defined in subclasses
namespace context {
// UContextFactory
-
-UContextFactory::UContextFactory() : SwappedContextFactory("UContextFactory") {}
-UContextFactory::~UContextFactory() = default;
-
Context* UContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process)
{
if (parallel_)
ASAN_FINISH_SWITCH(fake_stack, &from->asan_ctx_->asan_stack_, &from->asan_ctx_->asan_stack_size_);
}
-void UContext::stop()
-{
- Context::stop();
- throw StopRequest();
-}
-
// ParallelUContext
-void ParallelUContext::run_all()
-{
-}
-
/** Run one particular simulated process on the current thread.
*
* Only applied to the N first elements of the parmap array, where N is the amount of worker threads in the parmap.
UContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process,
SwappedContextFactory* factory);
~UContext() override;
- void stop() override;
void swap_into(SwappedContext* to) override;
}
void suspend() override;
void resume() override;
-
- static void run_all();
};
class UContextFactory : public SwappedContextFactory {
public:
- UContextFactory();
- ~UContextFactory() override;
+ UContextFactory() : SwappedContextFactory("UContextFactory") {}
Context* create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
};