Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: Support Mutexes in DPOR
[simgrid.git] / src / kernel / actor / MutexObserver.hpp
1 /* Copyright (c) 2019-2022. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_MC_MUTEX_OBSERVER_HPP
7 #define SIMGRID_MC_MUTEX_OBSERVER_HPP
8
9 #include "simgrid/forward.h"
10 #include "src/kernel/activity/MutexImpl.hpp"
11 #include "src/kernel/actor/ActorImpl.hpp"
12 #include "src/kernel/actor/SimcallObserver.hpp"
13
14 #include <string>
15
16 namespace simgrid {
17 namespace kernel {
18 namespace actor {
19
20 /* All the observers of Mutex transitions are very similar, so implement them all together in this class */
21 class MutexObserver : public SimcallObserver {
22   mc::Transition::Type type_;
23   activity::MutexImpl* const mutex_ = nullptr;
24
25 public:
26   MutexObserver(ActorImpl* actor, mc::Transition::Type type, activity::MutexImpl* mutex);
27
28   void serialize(std::stringstream& stream) const override;
29   activity::MutexImpl* get_mutex() const { return mutex_; }
30   bool is_enabled() override;
31 };
32
33 } // namespace actor
34 } // namespace kernel
35 } // namespace simgrid
36
37 #endif