This commit is contained in:
Yota Toyama
2023-09-28 12:51:38 +10:00
committed by GitHub
parent 7f2429fe25
commit 1e54b65b9e
12 changed files with 42 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"dynamic_threads",
"free_by_borrow",

View File

@@ -2,7 +2,7 @@
name = "dynamic_threads"
version = "0.1.0"
authors = ["Yota Toyama <raviqqe@gmail.com>"]
edition = "2018"
edition = "2021"
publish = false
[dependencies]

View File

@@ -1,5 +1,3 @@
extern crate bdwgc_alloc;
use bdwgc_alloc::Allocator;
use std::alloc::Layout;
@@ -14,7 +12,7 @@ fn main() {
unsafe { Allocator::register_current_thread().unwrap() }
for _ in 0..100 {
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
let _ = unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
unsafe { Allocator::unregister_current_thread() }

View File

@@ -2,7 +2,7 @@
name = "free_by_borrow"
version = "0.1.0"
authors = ["Yota Toyama <raviqqe@gmail.com>"]
edition = "2018"
edition = "2021"
publish = false
[dependencies]

View File

@@ -1,5 +1,3 @@
extern crate bdwgc_alloc;
use bdwgc_alloc::Allocator;
#[global_allocator]

View File

@@ -2,7 +2,7 @@
name = "free_by_gc"
version = "0.1.0"
authors = ["Yota Toyama <raviqqe@gmail.com>"]
edition = "2018"
edition = "2021"
publish = false
[dependencies]

View File

@@ -1,5 +1,3 @@
extern crate bdwgc_alloc;
use bdwgc_alloc::Allocator;
use std::alloc::Layout;
@@ -10,6 +8,6 @@ fn main() {
unsafe { Allocator::initialize() }
loop {
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
let _ = unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
}

View File

@@ -2,7 +2,7 @@
name = "static_threads"
version = "0.1.0"
authors = ["Yota Toyama <raviqqe@gmail.com>"]
edition = "2018"
edition = "2021"
publish = false
[dependencies]

View File

@@ -1,5 +1,3 @@
extern crate bdwgc_alloc;
use bdwgc_alloc::Allocator;
use std::alloc::Layout;
@@ -13,7 +11,7 @@ fn main() {
unsafe { Allocator::register_current_thread().unwrap() }
loop {
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
let _ = unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
});