Definition (Builder -> immutable shared MachineDef): - Named hierarchical states, events by name or enum identifier (P2996), states_from_enum, initial/parallel composites, shallow/deep history, deferred events, per-state timeouts, guards, entry/exit/transition actions (coroutine Task<void> or sync, wrapped), internal transitions. - build() validates (initial children, transition endpoints) and flattens into index-addressed vectors with depth info for LCA. Machine (one consumer, many producers): - post() is lock-free from any thread: Vyukov MPSC push + counting- semaphore park/wake; the single consumer (owned worker, or embedder via run_pending) owns all mutable machine state with zero locks. - Observation via seqlock over a trivially-copyable StateSnapshot of active leaves; readers retry, writer is wait-free, no heap. - Run-to-completion: innermost-first transition resolution per region, LCA-based exit/entry ordering, history snapshotted at exit time, deferred events re-injected FIFO after each state change, timers via deadline park (generation counters kill stale fires), orthogonal regions dispatched independently on the single consumer. - co_await machine.send(ev) / send_wait() resolve with SendResult after the step; actions are driven to completion on the consumer's ManualExecutor before the step ends. - swap_definition: atomic<shared_ptr> definition swap between steps; identical active-leaf names adopt seamlessly (no entry re-runs, queue intact), otherwise initial configuration; history remapped by name. - serialize_state()/restore_state(): JSON by state *names* for hot-reload and persistence; restore re-activates silently. - start() returns only once the initial configuration is entered. 40 new tests: semantics (ordering, guards, internal/self transitions), hierarchy + both history kinds, defer FIFO, parallel regions, timers, coroutine actions, awaitable/blocking send, serialize/restore round trips, seamless + fallback hot swap, and stress: 8 producers x 10k with per-producer FIFO assertion, 4-reader seqlock tear check, 50 definition swaps under sustained load. Green under ASan+UBSan, stable across repeated runs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6 lines
1.1 KiB
Plaintext
6 lines
1.1 KiB
Plaintext
where possible for logger add colors, also add configurable patterns(like threadId, service\custom, time level, etc) and allow user to change their positions and apperance, and allow user define custom, also allow for file logger, have ability to
|
|
split by levels into differen files(have one file which gonna output all levels), add saving to history. I wanna that state machine\fsm is class which should be inherited, states should be define as class\struct inside class which inherited base class
|
|
of fsm\state machine, then user should write realisation how each state should behave and each state should return or another state, or fail, or success. You should make only one realisation FSM, it should async by default, have ability to nest other
|
|
state machines to enter to them and wait their result, fsm should be dynamic(this means not all states always gonna be, some of them can be optional on specific conditions). Also i wanna that your create service\manager which can be used as
|
|
archistrator of FSM. Also define base class for services with interfaces which allow to call them, without directly depending on them
|