-/* Copyright (c) 2019-2022. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2023. The SimGrid Team. All rights reserved. */
/* 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. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_semaphore, ker_synchro, "Semaphore kernel-space implementation");
-namespace simgrid {
-namespace kernel {
-namespace activity {
+namespace simgrid::kernel::activity {
/* -------- Acquisition -------- */
void SemAcquisitionImpl::finish()
{
xbt_assert(simcalls_.size() == 1, "Unexpected number of simcalls waiting: %zu", simcalls_.size());
- smx_simcall_t simcall = simcalls_.front();
+ actor::Simcall* simcall = simcalls_.front();
simcalls_.pop_front();
if (surf_action_ != nullptr) { // A timeout was declared
{
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;
}
}
}
-} // namespace activity
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::activity