Refactor examples

This commit is contained in:
Yota Toyama
2019-04-24 15:38:06 +00:00
parent 6b1380f4bb
commit 9a689d5c00
3 changed files with 3 additions and 10 deletions

View File

@@ -13,11 +13,8 @@ fn main() {
let handle = std::thread::spawn(move || {
unsafe { Allocator::register_current_thread().unwrap() }
let mut _n =
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
for _ in 0..100 {
_n = unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) }
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
unsafe { Allocator::unregister_current_thread() }

View File

@@ -9,9 +9,7 @@ static GLOBAL_ALLOCATOR: Allocator = Allocator;
fn main() {
unsafe { Allocator::initialize() }
let mut _n = unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
loop {
_n = unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
}

View File

@@ -12,10 +12,8 @@ fn main() {
let handle = std::thread::spawn(move || {
unsafe { Allocator::register_current_thread().unwrap() }
let mut _n = unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
loop {
_n = unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) }
unsafe { GLOBAL_ALLOCATOR.alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
}
});