Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add SemaphoreImpl::piface_ (mimic MutexImpl).
[simgrid.git] / include / simgrid / s4u / Semaphore.hpp
index 6c93a8bc5767b4ba4b16c1bad7f7f6202a5e3b95..b100ba560dc500fa62cbd45a97f531ea9c14cf62 100644 (file)
@@ -29,21 +29,20 @@ namespace s4u {
  *
  */
 class XBT_PUBLIC Semaphore {
-  kernel::activity::SemaphoreImpl* const pimpl_;
-  std::atomic_int_fast32_t refcount_{0};
+  friend kernel::activity::SemaphoreImpl;
 
-  friend void intrusive_ptr_add_ref(Semaphore* sem);
-  friend void intrusive_ptr_release(Semaphore* sem);
+  kernel::activity::SemaphoreImpl* const pimpl_;
 
-public:
-  explicit Semaphore(unsigned int initial_capacity);
-  ~Semaphore();
+  friend void intrusive_ptr_add_ref(const Semaphore* sem);
+  friend void intrusive_ptr_release(const Semaphore* sem);
 
+  explicit Semaphore(kernel::activity::SemaphoreImpl* sem) : pimpl_(sem) {}
 #ifndef DOXYGEN
   Semaphore(Semaphore const&) = delete;            // No copy constructor. Use SemaphorePtr instead
   Semaphore& operator=(Semaphore const&) = delete; // No direct assignment either. Use SemaphorePtr instead
 #endif
 
+public:
   /** Constructs a new semaphore */
   static SemaphorePtr create(unsigned int initial_capacity);