Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics in contexts
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 6 Jan 2019 11:09:02 +0000 (12:09 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 6 Jan 2019 11:27:17 +0000 (12:27 +0100)
- Kill useless code
- Move a method to superclass
- Fix clang builds

src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextBoost.hpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextRaw.hpp
src/kernel/context/ContextSwapped.cpp
src/kernel/context/ContextSwapped.hpp
src/kernel/context/ContextUnix.cpp
src/kernel/context/ContextUnix.hpp

index 21dc80d..37a3481 100644 (file)
@@ -15,11 +15,6 @@ namespace kernel {
 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)
 {
@@ -111,12 +106,6 @@ void BoostContext::swap_into(SwappedContext* to_)
 #endif
 }
 
-void BoostContext::stop()
-{
-  Context::stop();
-  throw StopRequest();
-}
-
 // ParallelBoostContext
 void ParallelBoostContext::suspend()
 {
index 8cfed87..781cdd7 100644 (file)
@@ -36,7 +36,6 @@ public:
   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;
 
@@ -74,8 +73,8 @@ public:
 
 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
index 38f0191..622f5b4 100644 (file)
@@ -186,10 +186,6 @@ namespace context {
 
 // 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)
 {
@@ -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<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 */
index b014a1a..63fe3b7 100644 (file)
@@ -30,7 +30,6 @@ public:
   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;
 
@@ -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<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
 };
 }}} // namespace
index 4d277b7..2d53c8e 100644 (file)
@@ -227,6 +227,12 @@ void SwappedContext::suspend()
   }
 }
 
+void SwappedContext::stop()
+{
+  Context::stop();
+  throw StopRequest();
+}
+
 } // namespace context
 } // namespace kernel
 } // namespace simgrid
index cfb9361..2794f4a 100644 (file)
@@ -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
 
index 5b04cae..15cf789 100644 (file)
@@ -30,10 +30,6 @@ namespace kernel {
 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_)
@@ -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.
index bbdec21..d1aeff2 100644 (file)
@@ -29,7 +29,6 @@ public:
   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;
 
@@ -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<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process) override;
 };