Module unix

Module unix 

Source

StructsΒ§

StoreInterruptState πŸ”’
All necessary data for interrupting a store running WASM code on a thread.
ThreadInterruptState πŸ”’
Thread-related state; only PARTS of this struct are safe to access from within the interrupt handler.

ConstantsΒ§

THREAD_INTERRUPT_STATE πŸ”’
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:

StaticsΒ§

STORE_INTERRUPT_STATE πŸ”’
HashMap of all store states, accessible from all threads

FunctionsΒ§

install
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
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.
is_interrupted
Returns true if the store with the given ID has already been interrupted.
on_interrupted πŸ”’
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.
uninstall πŸ”’