~/talk

Modernizing Finite State Machines in C++ - Empower Simplicity & Boost Performance With std::variant

Talkat C++Now 2024 · 2024-04-29..05-03· [frontend-architecture, c-and-cpp]
links:none on file
slides:none on file

Implements a turnstile FSM (five states: locked, unlocked, payment processing, success, failed) using std::variant and std::optional, replacing virtual-state classes and enums, and adds a pluggable external transition table/strategy. The implementation removes heap allocation and virtual calls, keeps state-local data, and templates a TFSM engine that visits the active state. Benchmarks show std::variant about 90% faster than State pattern; after removing a timeout manager artifact it runs roughly 2% faster than enums and about 24× faster than the State pattern.

AI-written summary · about

  1. 0:00Introduction and speaker background
  2. 7:09Finite State Machines overview
  3. 12:54FSM implementation with enums
  4. 23:15Problems with enum-based FSMs
  5. 25:03State pattern for FSMs
  6. 35:24Modernizing FSMs with std::variant
  7. 43:40Performance comparison and benchmarks
  8. 55:34Advanced strategies and policy-based design
  9. 1:01:06Q&A and closing remarks
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.