Skip to content

Commit fbca675

Browse files
committed
add transaction
1 parent bfc07c8 commit fbca675

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

lib/transaction.cc

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
1+
/*
2+
* Copyright (C) 2019 TU Dresden
3+
* All rights reserved.
4+
*
5+
* Authors:
6+
* Tassilo Tanneberger
7+
*/
28

39
#include "reactor-cpp/transaction.hh"
410
#include "reactor-cpp/environment.hh"
@@ -9,27 +15,29 @@ reactor::Transaction::Transaction(Reactor* parent)
915
, parent_(parent) {}
1016

1117
auto reactor::Transaction::execute(bool recalculate) -> MutationResult {
12-
1318
this->environment_->start_mutation();
19+
20+
std::size_t index = 0;
1421
for (const auto& mutation : mutations_) {
15-
mutation->run();
16-
}
22+
if (mutation->run() != Success) {
23+
break;
24+
}
1725

18-
if (recalculate) {
19-
// parent_->remove_dependency_graph();
20-
// this->environment_->clear_dependency_graph();
21-
// this->environment_->build_dependency_graph(this->parent_);
26+
index++;
27+
}
2228

23-
// this->environment_
24-
// for (auto* reactor : this->environment_->top_level_reactors()) {
25-
// this->environment_->build_dependency_graph(reactor);
26-
// }
29+
if (index != mutations_.size()) {
30+
for (std::size_t i = 0; i < index; i++) {
31+
mutations_[index - i]->rollback();
32+
}
33+
}
2734

35+
if (recalculate) {
2836
this->environment_->calculate_indexes();
2937
}
3038

3139
this->environment_->stop_mutation();
32-
this->environment_->export_dependency_graph("./test.dot");
40+
3341
mutations_.clear();
3442
return Success;
3543
}

0 commit comments

Comments
 (0)