Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
import context
import time
import x.async as xasync
fn main() {
ctx, cancel := xasync.with_cancel()
ticks := chan int{cap: 4}
done := chan string{cap: 1}
worker := spawn fn [ctx, ticks, done] () {
xasync.every(ctx, 10 * time.millisecond, fn [ticks] (mut ctx context.Context) ! {
_ = ctx
ticks <- 1
}) or {
done <- err.msg()
return
}
done <- 'completed'
}()
if !wait_tick(ticks) || !wait_tick(ticks) {
eprintln('periodic job did not tick')
exit(1)
}
cancel()
select {
msg := <-done {
println('periodic stopped: ${msg}')
}
1 * time.second {
eprintln('periodic job did not stop')
exit(1)
}
}
worker.wait()
}
fn wait_tick(ticks chan int) bool {
select {
_ := <-ticks {
return true
}
1 * time.second {
return false
}
}
return false
}