Skip to main content

park_while_idle

Function park_while_idle 

Source
pub fn park_while_idle() -> Option<IdlePark>
Expand description

Guard form of on_thread_idle for a thread that is about to BLOCK: hands this thread’s heaps to the background scavenger, which does the idle work above while this thread sits in the kernel, and takes them back on drop.

Returns None when nothing was handed off (no scavenger running, this thread never allocated, or it is already parked). That case is deliberately NOT an inline sweep: a caller blocks far more often than it is truly idle. If this park is idle enough to afford the work, call on_thread_idle instead.

The thread must not allocate or free between the call and the drop – that is the precondition that lets another thread rewrite its free lists – which is why the guard is !Send and holds no data.