Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
java: cosmetics
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 2 Sep 2018 00:02:21 +0000 (02:02 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 2 Sep 2018 00:02:21 +0000 (02:02 +0200)
src/bindings/java/JavaContext.cpp
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
src/kernel/context/ContextThread.cpp

index 70c7069..37c96d7 100644 (file)
@@ -38,11 +38,10 @@ JavaContext* JavaContextFactory::self()
   return static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
 }
 
   return static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
 }
 
-JavaContext* JavaContextFactory::create_context(
-  std::function<void()> code,
-  void_pfn_smxprocess_t cleanup, smx_actor_t process)
+JavaContext* JavaContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup_fun,
+                                                smx_actor_t actor)
 {
 {
-  return this->new_context<JavaContext>(std::move(code), cleanup, process);
+  return this->new_context<JavaContext>(std::move(code), cleanup_fun, actor);
 }
 
 void JavaContextFactory::run_all()
 }
 
 void JavaContextFactory::run_all()
@@ -62,7 +61,6 @@ JavaContext::JavaContext(std::function<void()> code,
 
   /* If the user provided a function for the process then use it otherwise is the context for maestro */
   if (has_code()) {
 
   /* If the user provided a function for the process then use it otherwise is the context for maestro */
   if (has_code()) {
-    this->jprocess = nullptr;
     this->begin = xbt_os_sem_init(0);
     this->end = xbt_os_sem_init(0);
 
     this->begin = xbt_os_sem_init(0);
     this->end = xbt_os_sem_init(0);
 
@@ -81,7 +79,6 @@ JavaContext::JavaContext(std::function<void()> code,
       std::throw_with_nested(std::move(new_exception));
     }
   } else {
       std::throw_with_nested(std::move(new_exception));
     }
   } else {
-    this->thread = nullptr;
     xbt_os_thread_set_extra_data(this);
   }
 }
     xbt_os_thread_set_extra_data(this);
   }
 }
index 60ad851..7104651 100644 (file)
@@ -60,9 +60,8 @@ Context* ContextFactory::create_maestro(std::function<void()> code, smx_actor_t
     "Try using --cfg=contexts/factory:thread instead.\n");
 }
 
     "Try using --cfg=contexts/factory:thread instead.\n");
 }
 
-Context::Context(std::function<void()> code,
-    void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
-  : code_(std::move(code)), process_(process), iwannadie(false)
+Context::Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor)
+    : code_(std::move(code)), actor_(actor)
 {
   /* If the user provided a function for the process then use it.
      Otherwise, it is the context for maestro and we should set it as the
 {
   /* If the user provided a function for the process then use it.
      Otherwise, it is the context for maestro and we should set it as the
@@ -78,11 +77,11 @@ Context::~Context() = default;
 void Context::stop()
 {
   if (this->cleanup_func_)
 void Context::stop()
 {
   if (this->cleanup_func_)
-    this->cleanup_func_(this->process_);
-  this->process_->suspended_ = 0;
+    this->cleanup_func_(this->actor_);
+  this->actor_->suspended_ = 0;
 
   this->iwannadie = false;
 
   this->iwannadie = false;
-  simgrid::simix::simcall([this] { SIMIX_process_cleanup(this->process_); });
+  simgrid::simix::simcall([this] { SIMIX_process_cleanup(this->actor_); });
   this->iwannadie = true;
 }
 
   this->iwannadie = true;
 }
 
index 082677c..50f140c 100644 (file)
@@ -52,7 +52,7 @@ class XBT_PUBLIC Context {
 private:
   std::function<void()> code_;
   void_pfn_smxprocess_t cleanup_func_ = nullptr;
 private:
   std::function<void()> code_;
   void_pfn_smxprocess_t cleanup_func_ = nullptr;
-  smx_actor_t process_                = nullptr;
+  smx_actor_t actor_                  = nullptr;
 
 public:
   class StopRequest {
 
 public:
   class StopRequest {
@@ -68,7 +68,7 @@ public:
   private:
     std::string msg_;
   };
   private:
     std::string msg_;
   };
-  bool iwannadie;
+  bool iwannadie = false;
 
   Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
   Context(const Context&) = delete;
 
   Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
   Context(const Context&) = delete;
@@ -76,7 +76,7 @@ public:
 
   void operator()() { code_(); }
   bool has_code() const { return static_cast<bool>(code_); }
 
   void operator()() { code_(); }
   bool has_code() const { return static_cast<bool>(code_); }
-  smx_actor_t process() { return this->process_; }
+  smx_actor_t process() { return this->actor_; }
   void set_cleanup(void_pfn_smxprocess_t cleanup) { cleanup_func_ = cleanup; }
 
   // Virtual methods
   void set_cleanup(void_pfn_smxprocess_t cleanup) { cleanup_func_ = cleanup; }
 
   // Virtual methods
@@ -87,8 +87,8 @@ public:
 
 class XBT_PUBLIC AttachContext : public Context {
 public:
 
 class XBT_PUBLIC AttachContext : public Context {
 public:
-  AttachContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
-      : Context(std::move(code), cleanup_func, process)
+  AttachContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t actor)
+      : Context(std::move(code), cleanup_func, actor)
   {
   }
 
   {
   }
 
index 15a9ef7..008f641 100644 (file)
@@ -58,9 +58,8 @@ void ThreadContextFactory::run_all()
 
 // ThreadContext
 
 
 // ThreadContext
 
-ThreadContext::ThreadContext(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t process,
-                             bool maestro)
-    : AttachContext(std::move(code), cleanup, process), is_maestro_(maestro)
+ThreadContext::ThreadContext(std::function<void()> code, void_pfn_smxprocess_t cleanup, smx_actor_t actor, bool maestro)
+    : AttachContext(std::move(code), cleanup, actor), is_maestro_(maestro)
 {
   // We do not need the semaphores when maestro is in main,
   // but creating them anyway simplifies things when maestro is externalized
 {
   // We do not need the semaphores when maestro is in main,
   // but creating them anyway simplifies things when maestro is externalized