X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/97e476dc536bfd9fada85509d1c1f93714d46a10..adbdcbddadcbd685b72259874d1ebfd9cbbcc497:/src/s4u/s4u_Barrier.cpp diff --git a/src/s4u/s4u_Barrier.cpp b/src/s4u/s4u_Barrier.cpp index 80ce0e29b2..4b5bd3f2d2 100644 --- a/src/s4u/s4u_Barrier.cpp +++ b/src/s4u/s4u_Barrier.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2018-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2018-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. */ @@ -13,8 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_barrier, s4u, "S4U barrier"); -namespace simgrid { -namespace s4u { +namespace simgrid::s4u { /** @brief Create a new barrier * @@ -23,7 +22,7 @@ namespace s4u { BarrierPtr Barrier::create(unsigned int expected_actors) { auto* res = new kernel::activity::BarrierImpl(expected_actors); - return BarrierPtr(&res->piface_); + return BarrierPtr(&res->piface_, false); } /** @brief Block the current actor until all expected actors reach the barrier. @@ -37,12 +36,12 @@ int Barrier::wait() kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self(); if (MC_is_active() || MC_record_replay_is_active()) { // Split in 2 simcalls for transition persistency - kernel::actor::BarrierObserver lock_observer{issuer, mc::Transition::Type::BARRIER_LOCK, pimpl_}; + kernel::actor::BarrierObserver lock_observer{issuer, mc::Transition::Type::BARRIER_ASYNC_LOCK, pimpl_}; auto acquisition = kernel::actor::simcall_answered([issuer, this] { return pimpl_->acquire_async(issuer); }, &lock_observer); kernel::actor::BarrierObserver wait_observer{issuer, mc::Transition::Type::BARRIER_WAIT, acquisition.get()}; - return kernel::actor::simcall_blocking([issuer, acquisition] { return acquisition->wait_for(issuer, -1); }, + return kernel::actor::simcall_blocking([issuer, acquisition] { acquisition->wait_for(issuer, -1); }, &wait_observer); } else { // Do it in one simcall only @@ -53,6 +52,11 @@ int Barrier::wait() } } +std::string Barrier::to_string() const +{ + return pimpl_->to_string(); +} + void intrusive_ptr_add_ref(Barrier* barrier) { intrusive_ptr_add_ref(barrier->pimpl_); @@ -62,8 +66,7 @@ void intrusive_ptr_release(Barrier* barrier) { intrusive_ptr_release(barrier->pimpl_); } -} // namespace s4u -} // namespace simgrid +} // namespace simgrid::s4u /* **************************** Public C interface *************************** */