feat(fsm): structured scopes, race-loser join, boundary checkpoints, and bounded supervision
This commit is contained in:
1 parent
1dc51d5c43
commit
ef5312c4b3
11 files changed
+3819
-541
No files matched your search
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidFsmOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Fsm)
|
||||
|
||||
add_executable(void_fsm_only_consumer main.cpp)
|
||||
target_link_libraries(void_fsm_only_consumer PRIVATE Void::Fsm)
|
||||
target_compile_features(void_fsm_only_consumer PRIVATE cxx_std_26)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME FsmOnlyConsumer COMMAND void_fsm_only_consumer)
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <Void/Async/Executor.hpp>
|
||||
#include <Void/Async/Task.hpp>
|
||||
#include <Void/Fsm/Fsm.hpp>
|
||||
#include <Void/Fsm/Orchestrator.hpp>
|
||||
#include <Void/Time/Clock.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
struct ConsumerMachine : public Void::Fsm::Machine<ConsumerMachine> {
|
||||
using Success = int;
|
||||
|
||||
struct States {
|
||||
struct Start : State {
|
||||
Void::Coro::Task<Void::Fsm::StateKey> run()
|
||||
{
|
||||
co_return succeed(42);
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Void::Coro::Task<void> drive_consumer_fsm(
|
||||
Void::Fsm::ExecutionBinding binding,
|
||||
std::optional<Void::Result::Result<ConsumerMachine::Outcome<>>>* out)
|
||||
{
|
||||
ConsumerMachine fsm;
|
||||
*out = co_await fsm.run(binding);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
if (!Void::Fsm::terminal(Void::Fsm::Status::Faulted)) {
|
||||
return 1;
|
||||
}
|
||||
Void::Async::ManualExecutor exec;
|
||||
Void::Time::ManualClock clock;
|
||||
std::optional<Void::Result::Result<ConsumerMachine::Outcome<>>> out;
|
||||
Void::Async::spawn(
|
||||
exec,
|
||||
drive_consumer_fsm(
|
||||
{.executor = &exec, .clock = &clock}, &out));
|
||||
(void)exec.drain();
|
||||
if (!out.has_value() || !out->has_value() || !out->value().has_value()) {
|
||||
return 2;
|
||||
}
|
||||
return out->value().value() == 42 ? 0 : 3;
|
||||
}
|
||||
Reference in new issue
Block a user