1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! An example demonstrating multithreaded allocations.
//!
//! This exists an easy executable to tweak and run with profiling tools.
use refuse::{CollectionGuard, Ref};

fn main() {
    std::thread::scope(|s| {
        for _ in 0..16 {
            s.spawn(|| {
                let mut guard = CollectionGuard::acquire();
                for _ in 0..100 {
                    for _ in 0..100 {
                        Ref::new([0; 32], &guard);
                    }
                    guard.yield_to_collector();
                }
            });
        }
    });
}