X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6fdf44f81490b926235a98b2b5348395a4a1c135..85ebbe85ef3f238da71593b227793729479a5bff:/src/kernel/activity/SemaphoreImpl.cpp?ds=sidebyside diff --git a/src/kernel/activity/SemaphoreImpl.cpp b/src/kernel/activity/SemaphoreImpl.cpp index 3d67f8b504..5e8016ce79 100644 --- a/src/kernel/activity/SemaphoreImpl.cpp +++ b/src/kernel/activity/SemaphoreImpl.cpp @@ -87,12 +87,12 @@ SemAcquisitionImplPtr SemaphoreImpl::acquire_async(actor::ActorImpl* issuer) { auto res = SemAcquisitionImplPtr(new kernel::activity::SemAcquisitionImpl(issuer, this), true); - if (value_ <= 0) { - /* No free token in the semaphore; register the acquisition */ - ongoing_acquisitions_.push_back(res); - } else { + if (value_ > 0) { value_--; res->granted_ = true; + } else { + /* No free token in the semaphore; register the acquisition */ + ongoing_acquisitions_.push_back(res); } return res; }