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 Guard in the thread. Otherwise, it passes all its retired instances to a free flowing garbage container that can be cleaned up by other threads.

§Examples

use scc::ebr::{suspend, Guard, Shared};

assert!(suspend());

{
    let shared: Shared<usize> = Shared::new(47);
    let guard = Guard::new();
    shared.release(&guard);
    assert!(!suspend());
}

assert!(suspend());

let new_shared: Shared<usize> = Shared::new(17);
let guard = Guard::new();
new_shared.release(&guard);