diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 5cb5511..34e04c6 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -1,7 +1,9 @@ [workspace] +resolver = "2" members = [ "dynamic_threads", "free_by_borrow", "free_by_gc", "static_threads", + "tagged_pointer", ] diff --git a/examples/dynamic_threads/Cargo.toml b/examples/dynamic_threads/Cargo.toml index dcdd5f2..6ddf443 100644 --- a/examples/dynamic_threads/Cargo.toml +++ b/examples/dynamic_threads/Cargo.toml @@ -2,7 +2,7 @@ name = "dynamic_threads" version = "0.1.0" authors = ["Yota Toyama "] -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/examples/free_by_borrow/Cargo.toml b/examples/free_by_borrow/Cargo.toml index 9b49a48..79b4828 100644 --- a/examples/free_by_borrow/Cargo.toml +++ b/examples/free_by_borrow/Cargo.toml @@ -2,7 +2,7 @@ name = "free_by_borrow" version = "0.1.0" authors = ["Yota Toyama "] -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/examples/free_by_gc/Cargo.toml b/examples/free_by_gc/Cargo.toml index 49d09bd..74ca1a5 100644 --- a/examples/free_by_gc/Cargo.toml +++ b/examples/free_by_gc/Cargo.toml @@ -2,7 +2,7 @@ name = "free_by_gc" version = "0.1.0" authors = ["Yota Toyama "] -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/examples/static_threads/Cargo.toml b/examples/static_threads/Cargo.toml index aaa22b7..f6ee965 100644 --- a/examples/static_threads/Cargo.toml +++ b/examples/static_threads/Cargo.toml @@ -2,7 +2,7 @@ name = "static_threads" version = "0.1.0" authors = ["Yota Toyama "] -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/examples/tagged_pointer/Cargo.toml b/examples/tagged_pointer/Cargo.toml new file mode 100644 index 0000000..9257097 --- /dev/null +++ b/examples/tagged_pointer/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "tagged_pointer" +version = "0.1.0" +authors = ["Yota Toyama "] +edition = "2021" +publish = false + +[dependencies] +bdwgc-alloc = { path = "../.." } diff --git a/examples/tagged_pointer/src/main.rs b/examples/tagged_pointer/src/main.rs new file mode 100644 index 0000000..dda7581 --- /dev/null +++ b/examples/tagged_pointer/src/main.rs @@ -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 { + unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) }; + } + }); + + handle.join().unwrap(); +}