remove StackSource

Nothing in this library took StackSources, and it's probably too
high-level a concept to include here. Maybe later.
master
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)]
extern crate test;
extern crate lwkt;
use lwkt::{Context, StackSource};
use lwkt::Context;
static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<_>;
#[bench]
fn swap(b: &mut test::Bencher) {
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 ctx_ptr = ctx_slot;

View File

@ -1,13 +1,13 @@
#![feature(thread_local)]
extern crate lwkt;
use lwkt::{Context, StackSource};
use lwkt::Context;
#[thread_local]
static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<_>;
fn main() {
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 || {
println!("it's alive!");

View File

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

View File

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

View File

@ -1,8 +1,6 @@
// Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution.
//! Traits for stacks.
use core::prelude::*;
use core::fmt::{Debug, Display};
/// A trait for objects that hold ownership of a stack.
pub trait Stack {
@ -15,10 +13,3 @@ pub trait Stack {
/// so this is the lowest address.
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>;
}