''Review supported by Claude Code'' Control flow logic was scrutinised, and a race identified in the solution to pass on the display action to the GUI thread. Reconsidering the design, cross-thread synchronisation is now hinged rather on a single atomic buffer pointer, where the GUI thread notifies back completion of display work by setting that pointer to NULL. Overall this simplifies the control logic ---- As an aside, I setup an outline of topics for documentation in `DemoSpec.txt` and then instructed Claude to fill in the paragraphs, based on insight gained as part of the code validation / review. Furthermore, I requested to generate some diagrams that could be useful later when preparting the presentation
34 lines
1.3 KiB
Text
34 lines
1.3 KiB
Text
// Buffer-slot state engine of the io_uring video demo.
|
|
// Render: dot -Tsvg state-engine.dot -o state-engine.svg
|
|
//
|
|
// The BuffState of each ring slot is written and read ONLY by the Proactor
|
|
// thread; the single SHOW->FREE transition is triggered by the GUI thread
|
|
// clearing the atomic baton (toDisplay_), but observed and enacted here.
|
|
|
|
digraph BuffState {
|
|
rankdir=LR;
|
|
bgcolor="transparent";
|
|
labelloc="t";
|
|
fontname="sans-serif";
|
|
fontsize=14;
|
|
label="Life-cycle of one buffer »slot«";
|
|
|
|
node [shape=circle, fixedsize=true, width=0.9,
|
|
fontname="sans-serif", fontsize=12, style=filled, penwidth=1.4];
|
|
edge [fontname="sans-serif", fontsize=10];
|
|
|
|
FREE [fillcolor="#dbe9ff"];
|
|
READ [fillcolor="#ffedcc"];
|
|
FEED [fillcolor="#d8f0d8"];
|
|
SHOW [fillcolor="#e7d8ff"];
|
|
STOP [shape=doublecircle, width=0.85, fillcolor="#ffd6d6"];
|
|
|
|
FREE -> READ [label=" submit read\l addNextReadSubmissions()\l"];
|
|
READ -> FEED [label=" read completed OK\l handleCompletedRead()\l"];
|
|
READ -> STOP [label=" short read / EOF ", fontcolor="#a00000", color="#a00000"];
|
|
FEED -> SHOW [label=" publish frame\l maybeDisplayFrame()\l"];
|
|
SHOW -> FREE [label=" GUI released frame\l (toDisplay_ == nullptr)\l",
|
|
fontcolor="#5a2ca0", color="#5a2ca0", constraint=false];
|
|
|
|
{ rank=same; FREE; }
|
|
}
|