From 9a689d5c00cbf55fe021b7abd590b060667cbfb9 Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Wed, 24 Apr 2019 15:38:06 +0000 Subject: [PATCH] Refactor examples --- examples/dynamic_threads/src/main.rs | 5 +---- examples/gc_free/src/main.rs | 4 +--- examples/static_threads/src/main.rs | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/examples/dynamic_threads/src/main.rs b/examples/dynamic_threads/src/main.rs index 6e63a53..4efc531 100644 --- a/examples/dynamic_threads/src/main.rs +++ b/examples/dynamic_threads/src/main.rs @@ -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() } diff --git a/examples/gc_free/src/main.rs b/examples/gc_free/src/main.rs index 45a586f..5b2aaf6 100644 --- a/examples/gc_free/src/main.rs +++ b/examples/gc_free/src/main.rs @@ -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()) }; } } diff --git a/examples/static_threads/src/main.rs b/examples/static_threads/src/main.rs index da331f2..4dc6d99 100644 --- a/examples/static_threads/src/main.rs +++ b/examples/static_threads/src/main.rs @@ -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()) }; } });