Current (Confusing):
┌─────────────────────────────────────┐
│ RunState rs = Begin(window); │ ← "State"? What state does it hold?
│ │
│ Application.RunLoop(rs); │
│ │
│ Application.End(rs); │
└─────────────────────────────────────┘
Users think: "What state information does RunState contain?"
Reality: It's a token/handle for the Begin/End pairing
Proposed (Clear):
┌─────────────────────────────────────┐
│ RunToken token = Begin(window); │ ✅ Clear: it's a token, not state
│ │
│ Application.RunLoop(token); │
│ │
│ Application.End(token); │
└─────────────────────────────────────┘
Users understand: "It's a token for the Begin/End pairing"
Current (Confusing):
┌──────────────────────────────────────────┐
│ EndAfterFirstIteration = true; │ ← "End"? Like End() method?
│ │
│ RunState rs = Begin(window); │
│ │
│ RunLoop(rs); // Stops after 1 iteration│
│ │
│ End(rs); // This is "End" │
└──────────────────────────────────────────┘
Users think: "Does EndAfterFirstIteration call End()?"
Reality: It controls RunLoop() behavior, not End()
Proposed (Clear):
┌──────────────────────────────────────────┐
│ StopAfterFirstIteration = true; │ ✅ Clear: controls loop stopping
│ │
│ RunToken token = Begin(window); │
│ │
│ RunLoop(token); // Stops after 1 iter │
│ │
│ End(token); // Cleanup │
└──────────────────────────────────────────┘
Users understand: "Stop controls the loop, End cleans up"
This distinction is valuable and should be preserved:
┌─────────────────────────────────────────────────────────┐
│ RunLoop(token) │
│ │
│ Starts the driver's MainLoop │
│ Loops until stopped: │
│ │
│ ┌────────────────────────────────────────────────┐ │
│ │ while (toplevel.Running) │ │
│ │ { │ │
│ │ RunIteration(ref token); ←──────────┐ │ │
│ │ RunIteration(ref token); ←──────────┤ │ │
│ │ RunIteration(ref token); ←──────────┤ │ │
│ │ ... │ │ │
│ │ } │ │ │
│ └────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
│
│
┌─────────────▼───────────────┐
│ RunIteration(ref token) │
│ │
│ Processes ONE iteration: │
│ 1. Process driver events │
│ 2. Layout (if needed) │
│ 3. Draw (if needed) │
│ │
│ Returns immediately │
└─────────────────────────────┘
Key Insight:
- RunLoop = The LOOP itself (blocking, manages iterations)
- RunIteration = ONE iteration (immediate, processes events)
Application.Run(window)
┌───────────────────────────────────────────────────────┐
│ │
│ 1. Begin(window) → RunToken │
│ ┌─────────────────────────────────┐ │
│ │ • Initialize window │ │
│ │ • Layout views │ │
│ │ • Draw to screen │ │
│ └─────────────────────────────────┘ │
│ │
│ 2. RunLoop(token) │
│ ┌─────────────────────────────────┐ │
│ │ Start driver's MainLoop │ │
│ │ │ │
│ │ while (Running) { │ │
│ │ RunIteration(ref token) │ │
│ │ ├─ Process events │ │
│ │ ├─ Layout (if needed) │ │
│ │ └─ Draw (if needed) │ │
│ │ } │ │
│ │ │ │
│ │ Exits when: │ │
│ │ - RequestStop() called │ │
│ │ - StopAfterFirstIteration=true │ │
│ └─────────────────────────────────┘ │
│ │
│ 3. End(token) │
│ ┌─────────────────────────────────┐ │
│ │ • Cleanup window │ │
│ │ • Dispose token │ │
│ └─────────────────────────────────┘ │
│ │
└───────────────────────────────────────────────────────┘
When you need fine-grained control:
┌────────────────────────────────────────────┐
│ RunToken token = Begin(window); │
│ StopAfterFirstIteration = true; │ ✅ Clear: stop after one iter
│ │
│ while (!myCondition) │
│ { │
│ // Process one iteration │
│ RunIteration(ref token, first); │
│ first = false; │
│ │
│ // Your custom logic here │
│ DoCustomProcessing(); │
│ } │
│ │
│ End(token); │
└────────────────────────────────────────────┘
vs Old (Confusing):
┌────────────────────────────────────────────┐
│ RunState rs = Begin(window); │
│ EndAfterFirstIteration = true; │ ❌ Confusing: sounds like End()
│ │
│ while (!myCondition) │
│ { │
│ RunIteration(ref rs, first); │
│ first = false; │
│ DoCustomProcessing(); │
│ } │
│ │
│ End(rs); │
└────────────────────────────────────────────┘
User Action (e.g., Quit Key)
│
▼
┌────────────────────────┐
│ RequestStop(window) │ ✅ Keep: "Request" is clear
└────────────────────────┘
│
▼
┌────────────────────────┐
│ window.Running=false │
└────────────────────────┘
│
▼
┌────────────────────────┐
│ RunLoop exits │
└────────────────────────┘
│
▼
┌────────────────────────┐
│ End() cleans up │
└────────────────────────┘
✅ KEEP AS-IS:
Begin/End
┌──────────────────┐ ┌──────────────────┐
│ Begin(window) │ ... │ End(token) │
└──────────────────┘ └──────────────────┘
↑ ↑
│ │
Clear, concise Clear, concise
Not wordy Not wordy
RequestStop
┌─────────────────────┐
│ RequestStop() │
└─────────────────────┘
↑
│
"Request" appropriately
conveys non-blocking
RunLoop / RunIteration
┌─────────────────┐ ┌──────────────────┐
│ RunLoop() │ │ RunIteration() │
│ (the loop) │ │ (one iteration) │
└─────────────────┘ └──────────────────┘
↑ ↑
│ │
Distinction is important and valuable
╔═══════════════════════════════════╦═══════════════════════════════════╗
║ CURRENT ║ PROPOSED ║
╠═══════════════════════════════════╬═══════════════════════════════════╣
║ RunState rs = Begin(window); ║ RunToken token = Begin(window); ║
║ EndAfterFirstIteration = true; ║ StopAfterFirstIteration = true; ║
║ RunLoop(rs); ║ RunLoop(token); ║
║ End(rs); ║ End(token); ║
║ ║ ║
║ ❌ "State" misleading ║ ✅ "Token" clear ║
║ ❌ "End" confuses with End() ║ ✅ "Stop" aligns with RequestStop║
╚═══════════════════════════════════╩═══════════════════════════════════╝
CHANGE (2 names):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
RunState → RunToken
EndAfterFirstIteration → StopAfterFirstIteration
KEEP UNCHANGED:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Begin → Begin ✅
End → End ✅
RequestStop → RequestStop ✅
RunLoop → RunLoop ✅
RunIteration → RunIteration ✅
Run → Run ✅
Before:
┌─────────────────────────────────────────┐
│ Users think: │
│ • "What state does RunState hold?" │
│ • "Does EndAfterFirstIteration call │
│ End()?" │
│ │
│ Result: Confusion, questions │
└─────────────────────────────────────────┘
After:
┌─────────────────────────────────────────┐
│ Users understand: │
│ • "RunToken is a token" │
│ • "StopAfterFirstIteration controls │
│ the loop" │
│ │
│ Result: Clear, self-documenting │
└─────────────────────────────────────────┘
2 Changes Only:
RunState → RunToken (clear it's a token)EndAfterFirstIteration → StopAfterFirstIteration (clear it controls loop)Everything Else Stays:
Begin / End - Clear and conciseRequestStop - Appropriately non-blockingRunLoop / RunIteration - Valuable distinctionResult:
See TERMINOLOGY_PROPOSAL.md for complete analysis.