github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/imports/wasi_snapshot_preview1/sched.go (about) 1 package wasi_snapshot_preview1 2 3 import ( 4 "context" 5 6 "github.com/bananabytelabs/wazero/api" 7 "github.com/bananabytelabs/wazero/experimental/sys" 8 "github.com/bananabytelabs/wazero/internal/wasip1" 9 "github.com/bananabytelabs/wazero/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 }