Remove coroutine examples

This commit is contained in:
Yota Toyama
2019-09-30 22:08:13 -07:00
parent 468dedbadd
commit 052a896292
5 changed files with 0 additions and 81 deletions

View File

@@ -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",
] ]

View File

@@ -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"

View File

@@ -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 {}
}

View File

@@ -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"

View File

@@ -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();
}