scheduler: spawn_monitor / spawn_monitor_with — monitor registered on the child's slot before publish, so the Down always carries the real reason (spawn-then-monitor could race to NoProc); tests; channel test uses it
This commit is contained in:
@@ -1764,6 +1764,7 @@ pub(crate) fn install_actor(
|
||||
stack: crate::stack::Stack,
|
||||
supervisor: Pid,
|
||||
closure: Closure,
|
||||
monitor: Option<(crate::monitor::MonitorId, crate::channel::Sender<crate::monitor::Down>)>,
|
||||
) -> Pid {
|
||||
let slot = &inner.slots[idx as usize];
|
||||
let gen = slot.generation(); // stable: we own the vacant slot via the free list
|
||||
@@ -1791,6 +1792,12 @@ pub(crate) fn install_actor(
|
||||
cold.outstanding_handles = 1;
|
||||
cold.outcome = None;
|
||||
cold.pending_io_result = None;
|
||||
// `spawn_monitor`: register before publish, so no scheduler can run
|
||||
// (and finalize) the child before its monitor exists. Same slot as a
|
||||
// `monitor()` registration; the send-from-finalize path is unchanged.
|
||||
if let Some(m) = monitor {
|
||||
cold.monitors.push(m);
|
||||
}
|
||||
}
|
||||
slot.sp.store(sp, Ordering::Relaxed);
|
||||
// RFC 019: a fresh incarnation starts with its high-water at the fresh
|
||||
|
||||
Reference in New Issue
Block a user