Skip to content

Commit 1b034d6

Browse files
knoepfelgreenc-FNAL
authored andcommitted
Shift async_driver gear into park if exception from workflow graph
1 parent 6487281 commit 1b034d6

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

phlex/core/framework_graph.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ namespace phlex::experimental {
8282
finalize();
8383
run();
8484
} catch (std::exception const& e) {
85+
driver_.stop();
8586
spdlog::error(e.what());
8687
throw;
8788
} catch (...) {
89+
driver_.stop();
8890
spdlog::error("Unknown exception during graph execution");
8991
throw;
9092
}

phlex/core/fwd.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define PHLEX_CORE_FWD_HPP
33

44
#include "phlex/model/fwd.hpp"
5-
#include "phlex/utilities/async_driver.hpp"
65

76
#include <memory>
87

@@ -20,10 +19,6 @@ namespace phlex::experimental {
2019
using end_of_message_ptr = std::shared_ptr<end_of_message>;
2120
}
2221

23-
namespace phlex {
24-
using framework_driver = experimental::async_driver<data_cell_index_ptr>;
25-
}
26-
2722
#endif // PHLEX_CORE_FWD_HPP
2823

2924
// Local Variables:

phlex/driver.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
#include "phlex/configuration.hpp"
77
#include "phlex/core/fwd.hpp"
88
#include "phlex/model/product_store.hpp"
9+
#include "phlex/utilities/async_driver.hpp"
910

1011
#include <concepts>
1112
#include <memory>
1213

14+
namespace phlex {
15+
using framework_driver = experimental::async_driver<data_cell_index_ptr>;
16+
}
17+
1318
namespace phlex::experimental::detail {
1419

1520
// See note below.

phlex/utilities/async_driver.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ namespace phlex::experimental {
5050
return std::exchange(current_, std::nullopt);
5151
}
5252

53+
void stop()
54+
{
55+
// API that should only be called by the framework_graph
56+
gear_ = states::park;
57+
cv_.notify_one();
58+
}
59+
5360
void yield(RT rt)
5461
{
5562
std::unique_lock lock{mutex_};
5663
current_ = std::make_optional(std::move(rt));
5764
cv_.notify_one();
58-
cv_.wait(lock);
65+
cv_.wait(lock, [&] { return !current_.has_value() or gear_ == states::park; });
5966
}
6067

6168
private:

0 commit comments

Comments
 (0)