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:
Install interrupt state for the given store. Note that this function
may be called more than once, and correctly maintains a stack of
stores for which the state is installed.
Interrupt the store with the given ID. Best effort is made to ensure
interrupts are handled. However, there is no guarantee; under rare
circumstances, it is possible for the interrupt to be missed. One such
case is when the target thread is about to call WASM code but has not
yet made the call.
Called from within the signal handler to decide whether we should interrupt
the currently running WASM code. This function MAY return junk results in
case a signal comes in during an install or uninstall operation. However,
in such cases, there is no WASM code running, and the result will be ignored
by the signal handler anyway.