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:
parent
bdb6e0bd8b
commit
ff25697444
@ -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;
|
||||
|
@ -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!");
|
||||
|
@ -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::*; }
|
||||
|
@ -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,
|
||||
|
@ -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>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user