X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b527f16c02842442fbf77131ff132efd9ebb42aa..f927e5f98477c1422eab8a7c9640d2717a14ead1:/src/kernel/actor/SynchroObserver.hpp diff --git a/src/kernel/actor/SynchroObserver.hpp b/src/kernel/actor/SynchroObserver.hpp index e413a01138..15549bd0c7 100644 --- a/src/kernel/actor/SynchroObserver.hpp +++ b/src/kernel/actor/SynchroObserver.hpp @@ -18,7 +18,7 @@ namespace kernel { namespace actor { /* All the observers of Mutex transitions are very similar, so implement them all together in this class */ -class MutexObserver : public SimcallObserver { +class MutexObserver final : public SimcallObserver { mc::Transition::Type type_; activity::MutexImpl* const mutex_; @@ -26,8 +26,56 @@ public: MutexObserver(ActorImpl* actor, mc::Transition::Type type, activity::MutexImpl* mutex); void serialize(std::stringstream& stream) const override; + bool is_enabled() override; + activity::MutexImpl* get_mutex() const { return mutex_; } +}; + +/* This observer is used for SEM_LOCK and SEM_UNLOCK (only) */ +class SemaphoreObserver final : public SimcallObserver { + mc::Transition::Type type_; + activity::SemaphoreImpl* const sem_; + +public: + SemaphoreObserver(ActorImpl* actor, mc::Transition::Type type, activity::SemaphoreImpl* sem); + + void serialize(std::stringstream& stream) const override; + + activity::SemaphoreImpl* get_sem() const { return sem_; } +}; + +/* This observer is ued for SEM_WAIT, that is returning and needs the acquisition (in MC mode) */ +class SemaphoreAcquisitionObserver final : public ResultingSimcall { + mc::Transition::Type type_; + activity::SemAcquisitionImpl* const acquisition_; + const double timeout_; + +public: + SemaphoreAcquisitionObserver(ActorImpl* actor, mc::Transition::Type type, activity::SemAcquisitionImpl* acqui, + double timeout = -1.0); + + void serialize(std::stringstream& stream) 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 */ +class BarrierObserver final : public ResultingSimcall { + mc::Transition::Type type_; + activity::BarrierImpl* const barrier_ = nullptr; + activity::BarrierAcquisitionImpl* const acquisition_ = nullptr; + const double timeout_; + +public: + BarrierObserver(ActorImpl* actor, mc::Transition::Type type, activity::BarrierImpl* bar); + BarrierObserver(ActorImpl* actor, mc::Transition::Type type, activity::BarrierAcquisitionImpl* acqui, + double timeout = -1.0); + + void serialize(std::stringstream& stream) const override; + bool is_enabled() override; + + double get_timeout() const { return timeout_; } }; } // namespace actor