run_blocking

func run_blocking<A, T>(consume arg: A, consume body: (consume A) '[io, alloc, yield, panic, wait] -> T) -> T

Install the full set of root fallbacks — the same rows core's _with_host gives the program entry — and run body under them with arg passed through. A runtime-spawned closure must be self-contained across the boundary, and a closure cannot capture owned values, so state arrives as an argument.

View Source
pub func run_blocking<A, T>(consume arg: A, consume body: (consume A) '[io, alloc, yield, panic, wait] -> T) -> T {
	#handle 'io { request in
		'continue _io_host(request: request)
	}
	#handle 'alloc { allocation in
		'continue
	}
	#handle 'yield {
		'continue
	}
	#handle 'panic { message in
		write_string(fd: STDERR_FD, s: message)
		write_string(fd: STDERR_FD, s: "\n")
		_io_host(request: .exit(1))
		loop {}
	}
	// The tail-resumptive blocking fallback keeps constant stack depth.
	#handle 'wait { reasons in
		_block_wait(reasons: reasons)
		'continue
	}
	body(arg)
}