mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-05-29 09:58:55 -06:00
Remove coroutine examples
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"coroutines",
|
|
||||||
"dynamic_threads",
|
"dynamic_threads",
|
||||||
"free_by_borrow",
|
"free_by_borrow",
|
||||||
"free_by_gc",
|
"free_by_gc",
|
||||||
"static_threads",
|
"static_threads",
|
||||||
"suspended_coroutines",
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "coroutines"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Yota Toyama <raviqqe@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
publish = false
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bdwgc-alloc = { path = "../.." }
|
|
||||||
coroutine = "0.8"
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
extern crate bdwgc_alloc;
|
|
||||||
extern crate coroutine;
|
|
||||||
|
|
||||||
use bdwgc_alloc::Allocator;
|
|
||||||
use coroutine::asymmetric::Coroutine;
|
|
||||||
use std::alloc::Layout;
|
|
||||||
|
|
||||||
#[global_allocator]
|
|
||||||
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
unsafe { Allocator::initialize() }
|
|
||||||
Allocator::lock();
|
|
||||||
|
|
||||||
let handle = Coroutine::spawn(move |_, _| {
|
|
||||||
let bottom: u8 = 0;
|
|
||||||
unsafe { Allocator::set_stack_bottom(&bottom) }
|
|
||||||
Allocator::unlock();
|
|
||||||
|
|
||||||
loop {
|
|
||||||
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for _ in handle {}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "suspended_coroutines"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Yota Toyama <raviqqe@gmail.com>"]
|
|
||||||
edition = "2018"
|
|
||||||
publish = false
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bdwgc-alloc = { path = "../.." }
|
|
||||||
coroutine = "0.8"
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
extern crate bdwgc_alloc;
|
|
||||||
extern crate coroutine;
|
|
||||||
|
|
||||||
use bdwgc_alloc::Allocator;
|
|
||||||
use coroutine::asymmetric::Coroutine;
|
|
||||||
use std::alloc::Layout;
|
|
||||||
|
|
||||||
#[global_allocator]
|
|
||||||
static GLOBAL_ALLOCATOR: Allocator = Allocator;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
unsafe { Allocator::initialize() }
|
|
||||||
|
|
||||||
Allocator::lock();
|
|
||||||
let mut handle = Coroutine::spawn(move |me, _| {
|
|
||||||
let bottom: u8 = 0;
|
|
||||||
unsafe { Allocator::set_stack_bottom(&bottom) }
|
|
||||||
Allocator::unlock();
|
|
||||||
|
|
||||||
me.yield_with(42);
|
|
||||||
unsafe { Allocator::set_stack_bottom(&bottom) }
|
|
||||||
Allocator::unlock();
|
|
||||||
|
|
||||||
loop {
|
|
||||||
unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Allocator::lock();
|
|
||||||
assert_eq!(handle.resume(0).unwrap(), 42);
|
|
||||||
|
|
||||||
handle.resume(0).unwrap();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user