-/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-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. */
#include <simgrid/s4u/ConditionVariable.hpp>
#include <xbt/log.h>
+#include "src/kernel/activity/ActivityImpl.hpp"
#include "src/kernel/activity/ConditionVariableImpl.hpp"
#include "src/kernel/actor/SimcallObserver.hpp"
#include <mutex>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
ConditionVariablePtr ConditionVariable::create()
{
kernel::activity::ConditionVariableImpl* cond =
- kernel::actor::simcall([] { return new kernel::activity::ConditionVariableImpl(); });
+ kernel::actor::simcall_answered([] { return new kernel::activity::ConditionVariableImpl(); });
return ConditionVariablePtr(cond->get_iface(), false);
}
*/
void ConditionVariable::notify_one()
{
- simgrid::kernel::actor::simcall([this]() { pimpl_->signal(); });
+ simgrid::kernel::actor::simcall_answered([this]() { pimpl_->signal(); });
}
void ConditionVariable::notify_all()
{
- simgrid::kernel::actor::simcall([this]() { pimpl_->broadcast(); });
+ simgrid::kernel::actor::simcall_answered([this]() { pimpl_->broadcast(); });
}
void intrusive_ptr_add_ref(const ConditionVariable* cond)
intrusive_ptr_release(cond->pimpl_);
}
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
/* **************************** Public C interface *************************** */
sg_cond_t sg_cond_init()
int sg_cond_wait_for(sg_cond_t cond, sg_mutex_t mutex, double delay)
{
- std::unique_lock<simgrid::s4u::Mutex> lock(*mutex);
+ std::unique_lock lock(*mutex);
return cond->wait_for(lock, delay) == std::cv_status::timeout;
}