OxL Reference

warning blocking-in-task

warning Standard: [§8.1]

What it means#

An FFI function without @nonblocking may block its thread, which stalls other tasks scheduled on it. Such calls must run in the separate pool of blocking threads by being wrapped in blocking { ... } (§8.1).

Example#

oxl✓ checked in CI
extern c fn legacySleep(ms: i32)

fn pause() {
  unsafe { legacySleep(1000) }      // <- blocking-in-task
}
error
blocking-in-task

How to fix#

oxl✓ checked in CI
extern c fn legacySleep(ms: i32)

fn pause() {
  blocking { unsafe { legacySleep(1000) } }
}

Wrap the call in blocking { ... }, or mark the foreign function @nonblocking if it really never blocks. @nonblocking can also be written on an import c declaration to cover all imported functions:

oxl
@nonblocking
import c "math.h" { sqrt, cos }

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides