mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-05-30 10:28:56 -06:00
@@ -5,4 +5,5 @@ members = [
|
|||||||
"free_by_borrow",
|
"free_by_borrow",
|
||||||
"free_by_gc",
|
"free_by_gc",
|
||||||
"static_threads",
|
"static_threads",
|
||||||
|
"tagged_pointer",
|
||||||
]
|
]
|
||||||
|
|||||||
9
examples/tagged_pointer/Cargo.toml
Normal file
9
examples/tagged_pointer/Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "tagged_pointer"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Yota Toyama <raviqqe@gmail.com>"]
|
||||||
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bdwgc-alloc = { path = "../.." }
|
||||||
21
examples/tagged_pointer/src/main.rs
Normal file
21
examples/tagged_pointer/src/main.rs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
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 {
|
||||||
|
let _ = unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
handle.join().unwrap();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user