@@ -100,8 +100,8 @@ std::string FileEngine::get_path_to_dataset() const
100100
101101void FileEngine::begin_pub_transaction ()
102102{
103- if (is_cancelled ( ))
104- throw TransactionCancelledException (XBT_THROW_POINT );
103+ if (is_transaction_canceled (current_pub_transaction_id_ + 1 ))
104+ throw TransactioncanceledException (XBT_THROW_POINT );
105105
106106 auto self = sg4::Actor::self ();
107107
@@ -115,12 +115,12 @@ void FileEngine::begin_pub_transaction()
115115 // Wait for the completion of the Publish activities from the previous transaction
116116 XBT_DEBUG (" Wait for the completion of %u publish activities from the previous transaction" ,
117117 file_pub_transaction_[self].size ());
118- while (!is_cancelled () && file_pub_transaction_[self].size () > 0 ) {
118+ while (!is_canceled () && file_pub_transaction_[self].size () > 0 ) {
119119 std::unique_lock lock (*(get_publishers ().get_mutex ()));
120120 pub_activities_completed_->wait (lock);
121121 }
122- if (is_cancelled ( ))
123- throw TransactionCancelledException (XBT_THROW_POINT );
122+ if (is_transaction_canceled (current_pub_transaction_id_ ))
123+ throw TransactioncanceledException (XBT_THROW_POINT );
124124 XBT_DEBUG (" All on-flight publish activities are completed. Proceed with the current transaction." );
125125 get_file_transport ()->clear_to_write_in_transaction (self);
126126 }
@@ -169,7 +169,7 @@ void FileEngine::pub_close()
169169
170170 XBT_DEBUG (" [%s] Wait for the completion of %u publish activities from the previous transaction" , get_cname (),
171171 file_pub_transaction_[self].size ());
172- while (!is_cancelled ( ) && file_pub_transaction_[self].size () > 0 ) {
172+ while (!is_transaction_canceled (current_pub_transaction_id_ ) && file_pub_transaction_[self].size () > 0 ) {
173173 std::unique_lock lock (*(get_publishers ().get_mutex ()));
174174 pub_activities_completed_->wait (lock);
175175 }
@@ -191,8 +191,8 @@ void FileEngine::pub_close()
191191
192192void FileEngine::begin_sub_transaction ()
193193{
194- if (is_cancelled ( ))
195- throw TransactionCancelledException (XBT_THROW_POINT );
194+ if (is_transaction_canceled (current_sub_transaction_id_ + 1 ))
195+ throw TransactioncanceledException (XBT_THROW_POINT );
196196
197197 // Only one subscriber has to do this
198198 if (!sub_transaction_in_progress_) {
@@ -204,12 +204,15 @@ void FileEngine::begin_sub_transaction()
204204 // We have publishers on that stream, wait for them to complete a transaction first
205205 if (not get_publishers ().is_empty ()) {
206206 std::unique_lock lock (*get_subscribers ().get_mutex ());
207- while (!is_cancelled () && completed_pub_transaction_id_ < current_sub_transaction_id_) {
207+ while (!is_transaction_canceled (current_sub_transaction_id_) &&
208+ completed_pub_transaction_id_ < current_sub_transaction_id_) {
208209 XBT_DEBUG (" Wait for publishers to end the transaction I need" );
209210 pub_transaction_completed_->wait (lock);
210211 }
211- if (is_cancelled ())
212- throw TransactionCancelledException (XBT_THROW_POINT );
212+ if (is_transaction_canceled (current_sub_transaction_id_)) {
213+ sub_transaction_in_progress_ = false ;
214+ throw TransactioncanceledException (XBT_THROW_POINT );
215+ }
213216 XBT_DEBUG (" Publishers stored metadata for that transaction, proceed" );
214217 }
215218}
@@ -221,17 +224,17 @@ void FileEngine::end_sub_transaction()
221224
222225 // The files subscribers need to read may not have been fully written. Wait to be notified completion of the publish
223226 // activities
224- if (!is_cancelled () && current_sub_transaction_id_ == current_pub_transaction_id_ &&
225- not get_publishers ().is_empty ()) {
227+ if (!is_transaction_canceled ( current_sub_transaction_id_) &&
228+ current_sub_transaction_id_ == current_pub_transaction_id_ && not get_publishers ().is_empty ()) {
226229 XBT_DEBUG (" Wait for the completion of publish activities from the current transaction" );
227230 pub_activities_completed_->wait (std::unique_lock (*get_subscribers ().get_mutex ()));
228231 XBT_DEBUG (" All on-flight publish activities are completed. Proceed with the subscribe activities." );
229232 }
230- if (is_cancelled ( )) {
233+ if (is_transaction_canceled (current_sub_transaction_id_ )) {
231234 transport->close_sub_files (self);
232235 transport->clear_to_read_in_transaction (self);
233236 sub_transaction_in_progress_ = false ;
234- throw TransactionCancelledException (XBT_THROW_POINT );
237+ throw TransactioncanceledException (XBT_THROW_POINT );
235238 }
236239
237240 // Subscriber get the list of files and size to read that has been build during the get() operations
@@ -243,12 +246,12 @@ void FileEngine::end_sub_transaction()
243246
244247 XBT_DEBUG (" Wait for the %d subscribe activities for the transaction" , file_sub_transaction_[self].size ());
245248 file_sub_transaction_[self].wait_all ();
246- if (is_cancelled ( )) {
249+ if (is_transaction_canceled (current_sub_transaction_id_ )) {
247250 file_sub_transaction_[self].clear ();
248251 transport->close_sub_files (self);
249252 transport->clear_to_read_in_transaction (self);
250253 sub_transaction_in_progress_ = false ;
251- throw TransactionCancelledException (XBT_THROW_POINT );
254+ throw TransactioncanceledException (XBT_THROW_POINT );
252255 }
253256 file_sub_transaction_[self].clear ();
254257 // Close files opened in this transaction
0 commit comments