@@ -110,12 +110,14 @@ protected:
110110
111111 EnclaveConnection (const std::string& name, Environment* enclave, const Duration& delay)
112112 : BaseDelayedConnection<T>(name, enclave, false , delay)
113- , log_{this ->fqn ()} {}
113+ , log_{this ->fqn ()}
114+ , logical_time_barrier_(enclave->scheduler ()) {}
114115
115116public:
116117 EnclaveConnection (const std::string& name, Environment* enclave)
117118 : BaseDelayedConnection<T>(name, enclave, false , Duration::zero())
118- , log_{this ->fqn ()} {}
119+ , log_{this ->fqn ()}
120+ , logical_time_barrier_(enclave->scheduler ()) {}
119121
120122 inline auto upstream_set_callback () noexcept -> PortCallback override {
121123 return [this ](const BasePort& port) {
@@ -136,8 +138,9 @@ public:
136138 };
137139 }
138140
139- inline auto acquire_tag (const Tag& tag, std::unique_lock<std::mutex>& lock, std::condition_variable& cv,
141+ inline auto acquire_tag (const Tag& tag, std::unique_lock<std::mutex>& lock,
140142 const std::function<bool (void )>& abort_waiting) -> bool override {
143+ reactor_assert (lock.owns_lock ());
141144 log_.debug () << " downstream tries to acquire tag " << tag;
142145
143146 if (this ->upstream_port () == nullptr ) {
@@ -164,7 +167,7 @@ public:
164167 }
165168
166169 // Wait until we receive a release_tag message from upstream
167- return logical_time_barrier_.acquire_tag (tag, lock, cv, abort_waiting);
170+ return logical_time_barrier_.acquire_tag (tag, lock, abort_waiting);
168171 }
169172
170173 void bind_upstream_port (Port<T>* port) override {
@@ -201,15 +204,15 @@ public:
201204 };
202205 }
203206
204- inline auto acquire_tag (const Tag& tag, std::unique_lock<std::mutex>& lock, std::condition_variable& cv,
207+ inline auto acquire_tag (const Tag& tag, std::unique_lock<std::mutex>& lock,
205208 const std::function<bool (void )>& abort_waiting) -> bool override {
206209 // Since this is a delayed connection, we can go back in time and need to
207210 // acquire the latest upstream tag that can create an event at the given
208211 // tag. We also need to consider that given a delay d and a tag g=(t, n),
209212 // for any value of n, g + d = (t, 0). Hence, we need to quire a tag with
210213 // the highest possible microstep value.
211214 auto upstream_tag = tag.subtract (this ->min_delay ());
212- return EnclaveConnection<T>::acquire_tag (upstream_tag, lock, cv, abort_waiting);
215+ return EnclaveConnection<T>::acquire_tag (upstream_tag, lock, abort_waiting);
213216 }
214217};
215218
@@ -230,10 +233,10 @@ public:
230233 };
231234 }
232235
233- inline auto acquire_tag (const Tag& tag, std::unique_lock<std::mutex>& lock, std::condition_variable& cv,
236+ inline auto acquire_tag (const Tag& tag, std::unique_lock<std::mutex>& lock,
234237 const std::function<bool (void )>& abort_waiting) -> bool override {
235238 this ->log_ .debug () << " downstream tries to acquire tag " << tag;
236- return PhysicalTimeBarrier::acquire_tag (tag, lock, cv , abort_waiting);
239+ return PhysicalTimeBarrier::acquire_tag (tag, lock, this -> environment ()-> scheduler () , abort_waiting);
237240 }
238241
239242 void bind_upstream_port (Port<T>* port) override { Connection<T>::bind_upstream_port (port); }
0 commit comments