pub fn with_syscall<F, R>(f: F) -> Rwhere
F: FnOnce() -> R,Expand description
Wrap a potentially-blocking operation so the go-lib scheduler can hand off this goroutine’s P to another M while the OS thread is in the kernel.
Calls [entersyscall][runtime::syscall::entersyscall] before f and
[exitsyscall][runtime::syscall::exitsyscall] after f returns. This is
a no-op when called outside the scheduler (before run).
§Example
go_lib::run(|| {
let data = go_lib::with_syscall(|| std::fs::read("file.txt"));
});