X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/27b8391954e453abb4e3e904b6663678163a0a26..3ea82f7e0ddd6a4582aecee0f0e4662664605f61:/src/kernel/activity/SemaphoreImpl.hpp diff --git a/src/kernel/activity/SemaphoreImpl.hpp b/src/kernel/activity/SemaphoreImpl.hpp index 913d761a11..e6dc57d6bb 100644 --- a/src/kernel/activity/SemaphoreImpl.hpp +++ b/src/kernel/activity/SemaphoreImpl.hpp @@ -10,23 +10,29 @@ #include #include "simgrid/s4u/Semaphore.hpp" -#include "src/simix/ActorImpl.hpp" +#include "src/kernel/actor/ActorImpl.hpp" namespace simgrid { namespace kernel { namespace activity { class XBT_PUBLIC SemaphoreImpl { + std::atomic_int_fast32_t refcount_{1}; + unsigned int value_; + public: + actor::SynchroList sleeping_; /* list of sleeping actors*/ + explicit SemaphoreImpl(unsigned int value) : value_(value){}; ~SemaphoreImpl() = default; SemaphoreImpl(SemaphoreImpl const&) = delete; SemaphoreImpl& operator=(SemaphoreImpl const&) = delete; - void acquire(smx_actor_t issuer, double timeout); + void acquire(actor::ActorImpl* issuer, double timeout); void release(); - bool would_block() { return (value_ <= 0); } + bool would_block() { return (value_ == 0); } + unsigned int get_capacity() { return value_; } friend void intrusive_ptr_add_ref(SemaphoreImpl* sem) @@ -39,12 +45,6 @@ public: if (sem->refcount_.fetch_sub(1) == 1) delete sem; } - - unsigned int value_; - actor::SynchroList sleeping_; /* list of sleeping actors*/ - -private: - std::atomic_int_fast32_t refcount_{1}; }; } // namespace activity } // namespace kernel