github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/imports/wasi_snapshot_preview1/sched.go (about) 1 package wasi_snapshot_preview1 2 3 import ( 4 "context" 5 6 "github.com/wasilibs/wazerox/api" 7 "github.com/wasilibs/wazerox/experimental/sys" 8 "github.com/wasilibs/wazerox/internal/wasip1" 9 "github.com/wasilibs/wazerox/internal/wasm" 10 ) 11 12 // schedYield is the WASI function named SchedYieldName which temporarily 13 // yields execution of the calling thread. 14 // 15 // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-sched_yield---errno 16 var schedYield = newHostFunc(wasip1.SchedYieldName, schedYieldFn, nil) 17 18 func schedYieldFn(_ context.Context, mod api.Module, _ []uint64) sys.Errno { 19 sysCtx := mod.(*wasm.ModuleInstance).Sys 20 sysCtx.Osyield() 21 return 0 22 }