Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code simplification + replace a FIXME with an assert
[simgrid.git] / src / kernel / activity / ConditionVariableImpl.hpp
index e0634e6..7945f2a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -7,22 +7,33 @@
 #define SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLEIMPL_HPP
 
 #include "simgrid/s4u/ConditionVariable.hpp"
-#include "src/simix/ActorImpl.hpp"
+#include "src/kernel/actor/ActorImpl.hpp"
 #include <boost/intrusive/list.hpp>
 
-struct s_smx_cond_t {
-  s_smx_cond_t() : cond_(this) {}
+namespace simgrid {
+namespace kernel {
+namespace activity {
 
+class XBT_PUBLIC ConditionVariableImpl {
+public:
+  ConditionVariableImpl();
+  ~ConditionVariableImpl();
+
+  actor::SynchroList sleeping_; /* list of sleeping processes */
+  MutexImpl* mutex_ = nullptr;
+  s4u::ConditionVariable cond_;
+
+  void broadcast();
+  void signal();
+  void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer);
+
+private:
   std::atomic_int_fast32_t refcount_{1};
-  smx_mutex_t mutex = nullptr;
-  simgrid::kernel::actor::SynchroList sleeping; /* list of sleeping processes */
-  simgrid::s4u::ConditionVariable cond_;
+  friend void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
+  friend void intrusive_ptr_release(ConditionVariableImpl* cond);
 };
-
-XBT_PRIVATE smx_cond_t SIMIX_cond_init();
-XBT_PRIVATE void SIMIX_cond_broadcast(smx_cond_t cond);
-XBT_PRIVATE void SIMIX_cond_signal(smx_cond_t cond);
-XBT_PRIVATE void intrusive_ptr_add_ref(s_smx_cond_t* cond);
-XBT_PRIVATE void intrusive_ptr_release(s_smx_cond_t* cond);
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
 
 #endif