X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1a64ca4c11a1eb7ba2ecd102f877ac571486a034..f7b8f22f56d0a63d3a13058dfac718bc7ebaf32f:/include/simgrid/s4u/Semaphore.hpp diff --git a/include/simgrid/s4u/Semaphore.hpp b/include/simgrid/s4u/Semaphore.hpp index f0c89163e4..d3e2c58d5b 100644 --- a/include/simgrid/s4u/Semaphore.hpp +++ b/include/simgrid/s4u/Semaphore.hpp @@ -7,7 +7,6 @@ #define SIMGRID_S4U_SEMAPHORE_HPP #include -#include namespace simgrid { namespace s4u { @@ -29,29 +28,32 @@ namespace s4u { * */ class XBT_PUBLIC Semaphore { - kernel::activity::SemaphoreImpl* const pimpl_; - std::atomic_int_fast32_t refcount_{0}; +#ifndef DOXYGEN + friend kernel::activity::SemaphoreImpl; + friend void kernel::activity::intrusive_ptr_release(kernel::activity::SemaphoreImpl* sem); +#endif - 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) {} + ~Semaphore() = default; #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); void acquire(); - int acquire_timeout(double timeout); + bool acquire_timeout(double timeout); void release(); int get_capacity() const; - int would_block() const; + bool would_block() const; }; } // namespace s4u