*/
class RawContext : public SwappedContext {
public:
- RawContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
- ~RawContext() override;
- void stop() override;
+ RawContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process,
+ SwappedContextFactory* factory);
void swap_into(SwappedContext* to) override;
static void wrapper(void* arg);
};
-class ParallelRawContext : public RawContext {
+class RawContextFactory : public SwappedContextFactory {
public:
- ParallelRawContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
- : RawContext(std::move(code), cleanup_func, process)
- {
- }
- void suspend() override;
- void resume() override;
+ RawContextFactory() : SwappedContextFactory("RawContextFactory") {}
- static void initialize();
- static void finalize();
- static void run_all();
-
-private:
- static simgrid::xbt::Parmap<smx_actor_t>* parmap_;
- static std::vector<ParallelRawContext*> workers_context_;
- static std::atomic<uintptr_t> threads_working_;
- static uintptr_t thread_local worker_id_;
-};
-
-class RawContextFactory : public ContextFactory {
-public:
- RawContextFactory();
- ~RawContextFactory() override;
Context* create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
- void run_all() override;
-
-private:
- bool parallel_;
};
}}} // namespace