Files
bdwgc-rust/examples/static_threads/src/main.rs
2019-04-30 15:28:16 +00:00

22 lines
463 B
Rust

extern crate bdwgc_alloc;
use bdwgc_alloc::Allocator;
use std::alloc::Layout;
#[global_allocator]
static GLOBAL_ALLOCATOR: Allocator = Allocator;
fn main() {
unsafe { Allocator::initialize() }
let handle = std::thread::spawn(move || {
unsafe { Allocator::register_current_thread().unwrap() }
loop {
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
});
handle.join().unwrap();
}