mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-05-29 18:08:56 -06:00
Replace disable/enable functions with lock/unlock
This commit is contained in:
@@ -10,12 +10,12 @@ static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
||||
|
||||
fn main() {
|
||||
unsafe { Allocator::initialize() }
|
||||
Allocator::disable_gc();
|
||||
Allocator::lock();
|
||||
|
||||
let handle = Coroutine::spawn(move |_, _| {
|
||||
let bottom: u8 = 0;
|
||||
unsafe { Allocator::set_stack_bottom(&bottom) }
|
||||
Allocator::enable_gc();
|
||||
Allocator::unlock();
|
||||
|
||||
loop {
|
||||
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
||||
|
||||
@@ -11,22 +11,22 @@ static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
||||
fn main() {
|
||||
unsafe { Allocator::initialize() }
|
||||
|
||||
Allocator::disable_gc();
|
||||
Allocator::lock();
|
||||
let mut handle = Coroutine::spawn(move |me, _| {
|
||||
let bottom: u8 = 0;
|
||||
unsafe { Allocator::set_stack_bottom(&bottom) }
|
||||
Allocator::enable_gc();
|
||||
Allocator::unlock();
|
||||
|
||||
me.yield_with(42);
|
||||
unsafe { Allocator::set_stack_bottom(&bottom) }
|
||||
Allocator::enable_gc();
|
||||
Allocator::unlock();
|
||||
|
||||
loop {
|
||||
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
||||
}
|
||||
});
|
||||
|
||||
Allocator::disable_gc();
|
||||
Allocator::lock();
|
||||
assert_eq!(handle.resume(0).unwrap(), 42);
|
||||
|
||||
handle.resume(0).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user