Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow actor transitions to be shared
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Fri, 17 Feb 2023 10:47:50 +0000 (11:47 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Mon, 20 Feb 2023 09:46:02 +0000 (10:46 +0100)
Transitions that were stored in `ActorState`
prior to this commit were stored as `std::unique_ptr`
instances. But UDPOR events need to hold
references to the transitions that they are
"associated with". While UDPOR will discard events
at the appropriate time, we want to make sure the
reference to the transition in some `ActorState`
(ultimately in some `State` instance) remains
valid event after UDPOR discard the State object.
This could e.g. be helpful while debugging

src/mc/api/ActorState.hpp
src/mc/api/RemoteApp.cpp

index 6af8bcc..9f29307 100644 (file)
@@ -53,7 +53,7 @@ class ActorState {
    * This means there may be a way to store the list once and apply differences
    * rather than repeating elements frequently.
    */
-  std::vector<std::unique_ptr<Transition>> pending_transitions_;
+  std::vector<std::shared_ptr<Transition>> pending_transitions_;
 
   /* Possible exploration status of an actor transition in a state.
    * Either the checker did not consider the transition, or it was considered and still to do, or considered and
@@ -86,7 +86,7 @@ class ActorState {
 public:
   ActorState(aid_t aid, bool enabled, unsigned int max_consider) : ActorState(aid, enabled, max_consider, {}) {}
 
-  ActorState(aid_t aid, bool enabled, unsigned int max_consider, std::vector<std::unique_ptr<Transition>> transitions)
+  ActorState(aid_t aid, bool enabled, unsigned int max_consider, std::vector<std::shared_ptr<Transition>> transitions)
       : pending_transitions_(std::move(transitions)), aid_(aid), max_consider_(max_consider), enabled_(enabled)
   {
   }
index ad68366..ee1627f 100644 (file)
@@ -225,10 +225,10 @@ void RemoteApp::get_actors_status(std::map<aid_t, ActorState>& whereto) const
                "(currently %d), but only %d transition(s) was/were said to be encoded",
                actor.max_considered, actor.n_transitions);
 
-    auto actor_transitions = std::vector<std::unique_ptr<Transition>>(actor.n_transitions);
+    auto actor_transitions = std::vector<std::shared_ptr<Transition>>(actor.n_transitions);
     for (int times_considered = 0; times_considered < actor.n_transitions; times_considered++, probes_iter++) {
       std::stringstream stream((*probes_iter).buffer.data());
-      auto transition = std::unique_ptr<Transition>(deserialize_transition(actor.aid, times_considered, stream));
+      auto transition = std::shared_ptr<Transition>(deserialize_transition(actor.aid, times_considered, stream));
       actor_transitions[times_considered] = std::move(transition);
     }