warning blocking-in-task
Блокирующий FFI-вызов без blocking { }.
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#
extern c fn legacySleep(ms: i32)
fn pause() {
unsafe { legacySleep(1000) } // <- blocking-in-task
}error
blocking-in-task
How to fix#
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:
@nonblocking
import c "math.h" { sqrt, cos }