THREAD_INTERRUPT_STATE

Constant THREAD_INTERRUPT_STATE 

Source
const THREAD_INTERRUPT_STATE: LocalKey<UnsafeCell<ThreadInterruptState>>;
Expand description

Thread-local thread state. The book-keeping in a RefCell isn’t guaranteed to be signal-handler-safe, so we use an UnsafeCell instead. The cell is only accessed in leaf functions, so it should be safe. The only actually unsafe access happens if a signal comes in while another function is modifying the cell; In this case, [should_interrupt_now] will return junk results. This is still safe because:

  • should_interrupt_now only atomically accesses data from this cell
  • junk results shouldn’t matter if we’re not running WASM code