feat: add buildmanual target, faker demo, subprocess examples, and contributing sidebar to manual
Add Makefile buildmanual target for manual generation and include faker_demo.wren, subprocess_async_demo.wren, subprocess_concurrent_demo.wren, and subprocess_fiber_demo.wren example scripts. Update manual sidebar across api pages to link new web-server tutorial and contributing section with module architecture, pure-wren/c-backed modules, foreign classes, async patterns, testing, and documentation pages.
This commit is contained in:
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "subprocess" for Popen
|
||||
|
||||
System.print("=== Concurrent Ping Demo (Parallel Streaming) ===\n")
|
||||
|
||||
class PingTask {
|
||||
construct new(host, label) {
|
||||
_host = host
|
||||
_label = label
|
||||
_done = false
|
||||
_proc = Popen.new(["ping", "-c", "3", host])
|
||||
}
|
||||
|
||||
tick() {
|
||||
if (_done) return
|
||||
var chunk = _proc.stdout.read()
|
||||
if (chunk == "") {
|
||||
_done = true
|
||||
} else {
|
||||
for (line in chunk.split("\n")) {
|
||||
if (line.trim() != "") {
|
||||
System.print("[%(_label)] %(line)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isDone { _done }
|
||||
label { _label }
|
||||
host { _host }
|
||||
}
|
||||
|
||||
var tasks = [
|
||||
PingTask.new("127.0.0.1", "LOCAL"),
|
||||
PingTask.new("8.8.8.8", "GOOGLE"),
|
||||
PingTask.new("1.1.1.1", "CLOUDFLARE"),
|
||||
PingTask.new("9.9.9.9", "QUAD9"),
|
||||
PingTask.new("208.67.222.222", "OPENDNS")
|
||||
]
|
||||
|
||||
System.print("Starting 5 concurrent pings...")
|
||||
for (t in tasks) System.print(" %(t.label) -> %(t.host)")
|
||||
System.print("")
|
||||
|
||||
while (true) {
|
||||
var allDone = true
|
||||
for (task in tasks) {
|
||||
if (!task.isDone) {
|
||||
allDone = false
|
||||
task.tick()
|
||||
}
|
||||
}
|
||||
if (allDone) break
|
||||
}
|
||||
|
||||
System.print("")
|
||||
System.print("All 5 pings completed concurrently.")
|
||||
Reference in New Issue
Block a user