1 /* Copyright (c) 2012-2021. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLE_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLE_HPP
9 #include "simgrid/s4u/ConditionVariable.hpp"
10 #include "src/kernel/actor/ActorImpl.hpp"
11 #include <boost/intrusive/list.hpp>
17 class XBT_PUBLIC ConditionVariableImpl {
18 MutexImpl* mutex_ = nullptr;
19 s4u::ConditionVariable piface_;
20 actor::SynchroList sleeping_; /* list of sleeping actors*/
22 std::atomic_int_fast32_t refcount_{1};
23 friend void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
24 friend void intrusive_ptr_release(ConditionVariableImpl* cond);
27 ConditionVariableImpl() : piface_(this){};
29 void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
30 const s4u::ConditionVariable* get_iface() const { return &piface_; }
31 s4u::ConditionVariable* get_iface() { return &piface_; }
34 void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer);
36 } // namespace activity
38 } // namespace simgrid