Function compiler_interrupts::register [−][src]
pub unsafe fn register(
ir_interval: i64,
cycles_interval: i64,
handler: fn(_: i64)
)
Expand description
Registers a handler for Compiler Interrupts.
This function takes a IR interval, cycles interval, and function pointer to the Compiler Interrupts handler. The handler receives an approximation of the number of IR instructions since the last interrupt as the argument.
Note
This function is thread-specific, which means it only registers on the thread they called on.
This function should not be called multiple times. Consecutive calls will override the previous intervals and handler.
Safety
This function mutates a thread-local static variable which uses for the interrupt handler. Thread unsafety will not be introduced. However, calling the handler outside Rust would probably violate Rust’s safe memory model; hence the function is considered unsafe.
Examples
fn interrupt_handler(ic: i64) { println!("Compiler interrupt called with instruction count: {}", ic); } unsafe { compiler_interrupts::register(10000, 10000, interrupt_handler); }