-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdemo_fast.py
More file actions
executable file
·150 lines (128 loc) · 5.53 KB
/
demo_fast.py
File metadata and controls
executable file
·150 lines (128 loc) · 5.53 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env python3
"""
CsharpFlow Fast Demo Script - 45 Second Overview
Quick demonstration of all major CsharpFlow functionality in under 45 seconds.
Perfect for quick overviews, presentations, and getting a taste of the library.
"""
import os
import sys
import time
from pathlib import Path
from datetime import datetime
class Colors:
"""ANSI color codes"""
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
class FastDemo:
def __init__(self):
self.start_time = datetime.now()
def print_header(self, text: str):
print(f"\n{Colors.HEADER}{Colors.BOLD}{text}{Colors.ENDC}")
def print_step(self, text: str):
elapsed = (datetime.now() - self.start_time).total_seconds()
print(f"{Colors.OKCYAN}[{elapsed:04.1f}s]{Colors.ENDC} {text}")
def print_success(self, text: str):
print(f"{Colors.OKGREEN}✓{Colors.ENDC} {text}")
def fast_demo(self):
"""Complete demo in 45 seconds"""
self.print_header("🚀 CsharpFlow - 45 Second Demo")
print("Fast overview of C# coroutine library features...")
time.sleep(0.5)
# Kernel (3s)
self.print_step("🔧 Kernel: Central execution engine managing coroutines")
time.sleep(0.3)
self.print_step(" kernel.Step() processes all active generators")
time.sleep(0.7)
# Coroutines (4s)
self.print_step("⚡ Coroutines: Suspendable functions with yield return")
time.sleep(0.3)
self.print_step(" PlayerMovement, AI, Animation running in parallel")
time.sleep(0.7)
self.print_success("Multiple coroutines executing concurrently")
time.sleep(0.5)
# Barriers (5s)
self.print_step("🚧 Barriers: Wait for ALL tasks to complete")
time.sleep(0.3)
self.print_step(" Loading assets, connecting server, init graphics...")
time.sleep(0.8)
self.print_success("All initialization complete - game can start!")
time.sleep(0.4)
# Triggers (4s)
self.print_step("⚡ Triggers: Wait for ANY task to complete")
time.sleep(0.3)
self.print_step(" Player input OR 5-second timeout...")
time.sleep(0.8)
self.print_success("Timeout reached - proceeding with default action")
time.sleep(0.3)
# Futures (4s)
self.print_step("🔮 Futures: Asynchronous value resolution")
time.sleep(0.3)
self.print_step(" HTTP request to api.example.com/user/data...")
time.sleep(0.8)
self.print_success("Future resolved - coroutine resumed with user data")
time.sleep(0.3)
# Timers (4s)
self.print_step("⏰ Timers: Time-based execution")
time.sleep(0.3)
self.print_step(" PeriodicTimer(2s) - heartbeat every 2 seconds")
time.sleep(0.8)
self.print_success("342 users online - system monitoring active")
time.sleep(0.3)
# Sequences (4s)
self.print_step("📋 Sequences: Ordered step-by-step execution")
time.sleep(0.3)
self.print_step(" Draw Cards → Player Action → Combat → Cleanup")
time.sleep(0.8)
self.print_success("Game turn sequence completed successfully")
time.sleep(0.3)
# Complex Workflow (6s)
self.print_step("🎮 Complex Example: Multiplayer battle turn")
time.sleep(0.2)
self.print_step(" Barrier(init) → Trigger(input) → Future(damage)")
time.sleep(0.4)
self.print_step(" → Sequence(animations) → Barrier(cleanup)")
time.sleep(0.6)
self.print_success("Complex nested workflow completed!")
time.sleep(0.3)
# Error Handling (3s)
self.print_step("🛡️ Error Handling: Graceful failure recovery")
time.sleep(0.4)
self.print_step(" Network timeout → fallback server → cached data")
time.sleep(0.6)
self.print_success("Resilient systems with automatic recovery")
time.sleep(0.5)
# Summary (5s)
self.print_header("🎉 Demo Complete!")
elapsed = (datetime.now() - self.start_time).total_seconds()
print(f"Total time: {Colors.BOLD}{elapsed:.1f} seconds{Colors.ENDC}")
print()
print(f"{Colors.OKGREEN}CsharpFlow Features Demonstrated:{Colors.ENDC}")
print("✓ Kernel execution engine ✓ Async Futures")
print("✓ Coroutines & Generators ✓ Time-based Timers")
print("✓ Barriers (wait for all) ✓ Ordered Sequences")
print("✓ Triggers (wait for any) ✓ Error handling")
print()
print(f"{Colors.BOLD}Perfect for:{Colors.ENDC} Game loops, async workflows, state machines")
print(f"{Colors.BOLD}Get started:{Colors.ENDC} python3 build.py && python3 run_tests.py")
return 0
def main():
if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help']:
print("CsharpFlow Fast Demo - 45 Second Overview")
print()
print("Usage: python3 demo_fast.py")
print()
print("Quick demonstration of all major CsharpFlow features")
print("in under 45 seconds. No interaction required.")
print()
print("For the full interactive demo: python3 demo.py")
return 0
demo = FastDemo()
return demo.fast_demo()
if __name__ == "__main__":
sys.exit(main())