[go: up one dir, main page]

Function scc::ebr::suspend

source ·
pub fn suspend() -> bool
Expand description

Suspends the garbage collector of the current thread.

If returns false if there is an active Barrier in the thread. Otherwise, it passes all its garbage instances to a free flowing garbage container that can be cleaned up by other threads.

Examples

use scc::ebr::{suspend, Arc, Barrier};

assert!(suspend());

{
    let arc: Arc<usize> = Arc::new(47);
    let barrier = Barrier::new();
    arc.release(&barrier);
    assert!(!suspend());
}

assert!(suspend());

let new_arc: Arc<usize> = Arc::new(17);
let barrier = Barrier::new();
new_arc.release(&barrier);