Search results

There are no results.

std.io.start_blocking

Show source code
Hide source code
fn pub start_blocking {
  inko_process_start_blocking(_INKO.process)
}
fn pub static start_blocking

Signals the start of a C function call that may perform blocking IO operations.

This method should be called immediately before a C function call that might block the current OS thread. It must not be used for anything else.

If this method is called multiple times in the same process, it is required for there to be an equal number of calls to stop_blocking. For example, this is OK:

import std.io (start_blocking, stop_blocking)

start_blocking
start_blocking
perform_c_function_call(...)
stop_blocking
stop_blocking

Examples

import std.io (Error, start_blocking, stop_blocking)

fn extern open(path: Pointer[UInt8], flags: Int32, ...) -> Int32

start_blocking

let fd = open('test.txt'.to_pointer, 0 as Int32, 0 as Int32)
let err = stop_blocking

if fd as Int == -1 {
  panic('failed to open the file: ${Error.from_os_error(err)}')
}