X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/001737a15701027974d89260771284a45013d2cd..47950eebfede4e41862022469d15e5e4fe19c7ba:/src/kernel/activity/SemaphoreImpl.hpp?ds=sidebyside diff --git a/src/kernel/activity/SemaphoreImpl.hpp b/src/kernel/activity/SemaphoreImpl.hpp index 73faa7baf5..961a15ad0e 100644 --- a/src/kernel/activity/SemaphoreImpl.hpp +++ b/src/kernel/activity/SemaphoreImpl.hpp @@ -3,8 +3,8 @@ /* 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. */ -#ifndef SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP_ -#define SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP_ +#ifndef SIMGRID_KERNEL_ACTIVITY_SEMAPHORE_HPP +#define SIMGRID_KERNEL_ACTIVITY_SEMAPHORE_HPP #include #include @@ -17,7 +17,12 @@ 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; @@ -27,6 +32,7 @@ public: void acquire(actor::ActorImpl* issuer, double timeout); void release(); 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