-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnapshot.h
More file actions
40 lines (32 loc) · 1.39 KB
/
Copy pathsnapshot.h
File metadata and controls
40 lines (32 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// snapshot.h - the data the renderer draws each frame.
//
// REFERENCE NOTE: there is NO mutex here, on purpose. Every Flow_Runner and the
// Flow_View renderer are modules on the SAME Runtime, so they all advance on the
// one pump thread, round-robin. A runner writing its row and the view reading it
// never overlap - that is the core uniflow guarantee: single thread, no locks.
// The only other thread (stdin in main) touches just the clock and g_stop, never
// these rows.
#pragma once
#include <atomic>
#include <string>
namespace sim
{
constexpr int kRunnerCount = 5;
// Fixed dashboard layout (1-based rows). The renderer only ever draws rows
// 1..(kPromptRow-1); the stdin prompt lives on kPromptRow and is never touched
// by the renderer, so typed input is not clobbered by frame redraws.
constexpr int kPromptRow = 6 + kRunnerCount;
// One dashboard line. The runner owns its slot (indexed by ctor id).
struct RunnerRow
{
std::string name;
std::string step = "-"; // current step name - drives the "what is it doing" column
double percent = 0.0;
int lap = 0;
};
// Plain global state, pump-thread-only (see header note above).
extern RunnerRow g_rows[kRunnerCount];
// Cross-thread shutdown latch: set by the stdin loop, read by every flow's
// steps so they can return Done() and let WaitUntilIdle() return.
extern std::atomic<bool> g_stop;
} // namespace sim