Files
endorphin-tessera-gui/examples/cooperative-tasks.endor
T
2026-10-23 20:02:25 +08:00

81 lines
2.5 KiB
Plaintext

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))