X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c8de1d1065c327e9c93c7389946cc2652c7d0f20..fe1ed43699e1784d267f47d8c532e00cb344198d:/src/kernel/actor/SynchroObserver.hpp diff --git a/src/kernel/actor/SynchroObserver.hpp b/src/kernel/actor/SynchroObserver.hpp index 15549bd0c7..ffcfcabcf0 100644 --- a/src/kernel/actor/SynchroObserver.hpp +++ b/src/kernel/actor/SynchroObserver.hpp @@ -1,4 +1,4 @@ -/* 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. */ @@ -7,15 +7,14 @@ #define SIMGRID_MC_MUTEX_OBSERVER_HPP #include "simgrid/forward.h" +#include "src/kernel/activity/ConditionVariableImpl.hpp" #include "src/kernel/activity/MutexImpl.hpp" #include "src/kernel/actor/ActorImpl.hpp" #include "src/kernel/actor/SimcallObserver.hpp" #include -namespace simgrid { -namespace kernel { -namespace actor { +namespace simgrid::kernel::actor { /* All the observers of Mutex transitions are very similar, so implement them all together in this class */ class MutexObserver final : public SimcallObserver { @@ -26,6 +25,7 @@ public: MutexObserver(ActorImpl* actor, mc::Transition::Type type, activity::MutexImpl* mutex); void serialize(std::stringstream& stream) const override; + std::string to_string() const override; bool is_enabled() override; activity::MutexImpl* get_mutex() const { return mutex_; } @@ -40,6 +40,7 @@ public: SemaphoreObserver(ActorImpl* actor, mc::Transition::Type type, activity::SemaphoreImpl* sem); void serialize(std::stringstream& stream) const override; + std::string to_string() const override; activity::SemaphoreImpl* get_sem() const { return sem_; } }; @@ -55,12 +56,13 @@ public: double timeout = -1.0); void serialize(std::stringstream& stream) const override; + std::string to_string() const override; bool is_enabled() override; double get_timeout() const { return timeout_; } }; -/* This observer is ued for BARRIER_LOCK and BARRIER_WAIT. WAIT is returning and needs the acquisition */ +/* This observer is used for BARRIER_LOCK and BARRIER_WAIT. WAIT is returning and needs the acquisition */ class BarrierObserver final : public ResultingSimcall { mc::Transition::Type type_; activity::BarrierImpl* const barrier_ = nullptr; @@ -73,13 +75,33 @@ public: double timeout = -1.0); void serialize(std::stringstream& stream) const override; + std::string to_string() const override; bool is_enabled() override; double get_timeout() const { return timeout_; } }; -} // namespace actor -} // namespace kernel -} // namespace simgrid +class ConditionVariableObserver final : public ResultingSimcall { + //mc::Transition::Type type_; Will be used when we implement CV on the MC side + activity::ConditionVariableImpl* const cond_; + activity::MutexImpl* const mutex_; + const double timeout_; + +public: + ConditionVariableObserver(ActorImpl* actor, activity::ConditionVariableImpl* cond, activity::MutexImpl* mutex, + double timeout = -1.0) + : ResultingSimcall(actor, false), cond_(cond), mutex_(mutex), timeout_(timeout) + { + xbt_assert(mutex != nullptr, "Cannot wait on a condition variable without a valid mutex"); + } + void serialize(std::stringstream& stream) const override; + std::string to_string() const override; + bool is_enabled() override; + activity::ConditionVariableImpl* get_cond() const { return cond_; } + activity::MutexImpl* get_mutex() const { return mutex_; } + double get_timeout() const { return timeout_; } +}; + +} // namespace simgrid::kernel::actor #endif