remove StackSource

Nothing in this library took StackSources, and it's probably too
high-level a concept to include here. Maybe later.
This commit is contained in:
edef 2015-04-16 07:39:28 -04:00
parent bdb6e0bd8b
commit ff25697444
5 changed files with 7 additions and 25 deletions

View File

@ -3,14 +3,14 @@
#![feature(test)] #![feature(test)]
extern crate test; extern crate test;
extern crate lwkt; extern crate lwkt;
use lwkt::{Context, StackSource}; use lwkt::Context;
static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<_>; static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<_>;
#[bench] #[bench]
fn swap(b: &mut test::Bencher) { fn swap(b: &mut test::Bencher) {
unsafe { unsafe {
let stack = lwkt::os::StackSource.get_stack(4 << 20).unwrap(); let stack = lwkt::os::Stack::new(4 << 20).unwrap();
let mut ctx = Context::new(stack, move || { let mut ctx = Context::new(stack, move || {
let ctx_ptr = ctx_slot; let ctx_ptr = ctx_slot;

View File

@ -1,13 +1,13 @@
#![feature(thread_local)] #![feature(thread_local)]
extern crate lwkt; extern crate lwkt;
use lwkt::{Context, StackSource}; use lwkt::Context;
#[thread_local] #[thread_local]
static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<_>; static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<_>;
fn main() { fn main() {
unsafe { unsafe {
let stack = lwkt::os::StackSource.get_stack(4 << 20).unwrap(); let stack = lwkt::os::Stack::new(4 << 20).unwrap();
let mut ctx = Context::new(stack, move || { let mut ctx = Context::new(stack, move || {
println!("it's alive!"); println!("it's alive!");

View File

@ -13,7 +13,7 @@ extern crate core;
extern crate std; extern crate std;
pub use context::Context; pub use context::Context;
pub use stack::{Stack, StackSource}; pub use stack::Stack;
#[cfg(not(test))] #[cfg(not(test))]
mod std { pub use core::*; } mod std { pub use core::*; }

View File

@ -11,12 +11,6 @@ use self::std::io::Error as IoError;
use stack; use stack;
mod sys; mod sys;
#[derive(Copy, Clone)]
pub struct StackSource;
unsafe impl Send for StackSource {}
unsafe impl Sync for StackSource {}
#[allow(raw_pointer_derive)] #[allow(raw_pointer_derive)]
#[derive(Debug)] #[derive(Debug)]
pub struct Stack { pub struct Stack {
@ -26,11 +20,8 @@ pub struct Stack {
unsafe impl Send for Stack {} unsafe impl Send for Stack {}
impl stack::StackSource for StackSource { impl Stack {
type Output = Stack; pub fn new(size: usize) -> Result<Stack, IoError> {
type Error = IoError;
fn get_stack(&mut self, size: usize) -> Result<Stack, IoError> {
let page_size = sys::page_size(); let page_size = sys::page_size();
// round the page size up, // round the page size up,

View File

@ -1,8 +1,6 @@
// Copyright (c) 2015, edef <edef@edef.eu> // Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution. // See the LICENSE file included in this distribution.
//! Traits for stacks. //! Traits for stacks.
use core::prelude::*;
use core::fmt::{Debug, Display};
/// A trait for objects that hold ownership of a stack. /// A trait for objects that hold ownership of a stack.
pub trait Stack { pub trait Stack {
@ -15,10 +13,3 @@ pub trait Stack {
/// so this is the lowest address. /// so this is the lowest address.
fn limit(&self) -> *const u8; fn limit(&self) -> *const u8;
} }
/// A trait for objects that provide stacks of arbitrary size.
pub trait StackSource {
type Output: Stack;
type Error: Debug + Display = ();
fn get_stack(&mut self, size: usize) -> Result<Self::Output, Self::Error>;
}