From 15f9e0adbd11d2a0736440004a2f71ef9cfccab8 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 6 Jan 2019 12:09:02 +0100 Subject: [PATCH] Cosmetics in contexts - Kill useless code - Move a method to superclass - Fix clang builds --- src/kernel/context/ContextBoost.cpp | 11 ----------- src/kernel/context/ContextBoost.hpp | 5 ++--- src/kernel/context/ContextRaw.cpp | 23 ----------------------- src/kernel/context/ContextRaw.hpp | 7 ++----- src/kernel/context/ContextSwapped.cpp | 6 ++++++ src/kernel/context/ContextSwapped.hpp | 3 ++- src/kernel/context/ContextUnix.cpp | 14 -------------- src/kernel/context/ContextUnix.hpp | 6 +----- 8 files changed, 13 insertions(+), 62 deletions(-) diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index 21dc80d097..37a348195f 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -15,11 +15,6 @@ namespace kernel { namespace context { // BoostContextFactory - -BoostContextFactory::BoostContextFactory() : SwappedContextFactory("BoostContextFactory") {} - -BoostContextFactory::~BoostContextFactory() = default; - smx_context_t BoostContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process) { @@ -111,12 +106,6 @@ void BoostContext::swap_into(SwappedContext* to_) #endif } -void BoostContext::stop() -{ - Context::stop(); - throw StopRequest(); -} - // ParallelBoostContext void ParallelBoostContext::suspend() { diff --git a/src/kernel/context/ContextBoost.hpp b/src/kernel/context/ContextBoost.hpp index 8cfed87674..781cdd7a5a 100644 --- a/src/kernel/context/ContextBoost.hpp +++ b/src/kernel/context/ContextBoost.hpp @@ -36,7 +36,6 @@ public: BoostContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, SwappedContextFactory* factory); ~BoostContext() override; - void stop() override; void swap_into(SwappedContext* to) override; @@ -74,8 +73,8 @@ public: class BoostContextFactory : public SwappedContextFactory { public: - BoostContextFactory(); - ~BoostContextFactory() override; + BoostContextFactory() : SwappedContextFactory("BoostContextFactory") {} + Context* create_context(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override; }; }}} // namespace diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index 38f01918b0..622f5b48db 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -186,10 +186,6 @@ namespace context { // RawContextFactory -RawContextFactory::RawContextFactory() : SwappedContextFactory("RawContextFactory") {} - -RawContextFactory::~RawContextFactory() = default; - Context* RawContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process) { @@ -251,27 +247,8 @@ void RawContext::swap_into(SwappedContext* to_) 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(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode()); - parmap_->apply( - [](smx_actor_t process) { - ParallelRawContext* context = static_cast(process->context_); - context->resume(); - }, - simix_global->process_to_run); -} - void ParallelRawContext::suspend() { /* determine the next context */ diff --git a/src/kernel/context/ContextRaw.hpp b/src/kernel/context/ContextRaw.hpp index b014a1a37a..63fe3b783a 100644 --- a/src/kernel/context/ContextRaw.hpp +++ b/src/kernel/context/ContextRaw.hpp @@ -30,7 +30,6 @@ public: RawContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, SwappedContextFactory* factory); ~RawContext() override; - void stop() override; void swap_into(SwappedContext* to) override; @@ -57,14 +56,12 @@ public: } 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 code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override; }; }}} // namespace diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index 4d277b7ed7..2d53c8e4cf 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -227,6 +227,12 @@ void SwappedContext::suspend() } } +void SwappedContext::stop() +{ + Context::stop(); + throw StopRequest(); +} + } // namespace context } // namespace kernel } // namespace simgrid diff --git a/src/kernel/context/ContextSwapped.hpp b/src/kernel/context/ContextSwapped.hpp index cfb9361f57..2794f4a140 100644 --- a/src/kernel/context/ContextSwapped.hpp +++ b/src/kernel/context/ContextSwapped.hpp @@ -38,8 +38,9 @@ public: 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 diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index 5b04cae4c5..15cf789a31 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -30,10 +30,6 @@ namespace kernel { namespace context { // UContextFactory - -UContextFactory::UContextFactory() : SwappedContextFactory("UContextFactory") {} -UContextFactory::~UContextFactory() = default; - Context* UContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t process) { if (parallel_) @@ -120,18 +116,8 @@ void UContext::swap_into(SwappedContext* to_) 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. diff --git a/src/kernel/context/ContextUnix.hpp b/src/kernel/context/ContextUnix.hpp index bbdec21150..d1aeff2e28 100644 --- a/src/kernel/context/ContextUnix.hpp +++ b/src/kernel/context/ContextUnix.hpp @@ -29,7 +29,6 @@ public: UContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, SwappedContextFactory* factory); ~UContext() override; - void stop() override; void swap_into(SwappedContext* to) override; @@ -56,14 +55,11 @@ public: } 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 code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override; }; -- 2.20.1