// Preemption latency (issue #191, ADR 0046 piece 2): a busy actor burns // through its reduction budget, so an exit signal is delivered to it at // its loop's next entry. The spin is a self tail call — exactly the // entry that keeps the preemption point. With the point dropped from // every entry this hangs: nothing would ever interrupt `spin`. import std/io import std/process.{type proc, Down, Killed} fn spin :: n: Int -> () { spin (n + 1) } pub fn main :: -> () / { let busy = process.spawn fn { spin 0 } let seen = process.monitor busy process.kill busy let Down(_, why) = process.receive_forever seen match why { Killed -> io.println "killed", _ -> io.println "other" } } //> killed