docs: demonstrate cooperative Endor tasks and pending await scope
Verify Tessera GUI / verify (push) Failing after 9m45s

This commit is contained in:
2026-10-23 20:02:25 +08:00
parent 485c35c641
commit e0a7d8169c
4 changed files with 89 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
class CooperativeWork {
steps: Object
function run(self: CooperativeWork): Unit {
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
self.steps.increment()
}
}
left = CooperativeWork(ui.state(0))
right = CooperativeWork(ui.state(0))
leftTask = ui.spawn(left,"work",left.run)
rightTask = ui.spawn(right,"work",right.run)
leftStatus = TextBlock("")
rightStatus = TextBlock("")
leftStatus.bind("text",leftTask.status)
rightStatus.bind("text",rightTask.status)
page = Page()
page.title = "独立暂停调用"
page.render(Column(24,16,TextBlock("两个任务分别保存执行帧;在 REPL 查看 left.steps.value / right.steps.value",2),leftStatus,rightStatus))