parent
195350863a
commit
42db0ee5b1
|
@ -3,7 +3,7 @@ extern crate test;
|
||||||
extern crate lwkt;
|
extern crate lwkt;
|
||||||
use lwkt::{Context, Stack};
|
use lwkt::{Context, Stack};
|
||||||
|
|
||||||
static mut ctx_slot: *mut Context<SliceStack<'static>> = 0 as *mut Context<_>;
|
static mut ctx_slot: *mut Context<'static, SliceStack<'static>> = 0 as *mut Context<_>;
|
||||||
static mut stack_buf: [u8; 1024] = [0; 1024];
|
static mut stack_buf: [u8; 1024] = [0; 1024];
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
|
|
|
@ -3,7 +3,7 @@ extern crate test;
|
||||||
extern crate lwkt;
|
extern crate lwkt;
|
||||||
use lwkt::{Context, StackSource};
|
use lwkt::{Context, StackSource};
|
||||||
|
|
||||||
static mut ctx_slot: *mut Context<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) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ extern crate lwkt;
|
||||||
use lwkt::{Context, StackSource};
|
use lwkt::{Context, StackSource};
|
||||||
|
|
||||||
#[thread_local]
|
#[thread_local]
|
||||||
static mut ctx_slot: *mut Context<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 {
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
use core::marker::PhantomData;
|
||||||
use arch::Registers;
|
use arch::Registers;
|
||||||
use stack;
|
use stack;
|
||||||
use debug::StackId;
|
use debug::StackId;
|
||||||
|
|
||||||
pub struct Context<Stack: stack::Stack> {
|
pub struct Context<'a, Stack: stack::Stack> {
|
||||||
regs: Registers,
|
regs: Registers,
|
||||||
_stack_id: StackId,
|
_stack_id: StackId,
|
||||||
stack: Stack
|
stack: Stack,
|
||||||
|
_ref: PhantomData<&'a ()>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Stack> Context<Stack> where Stack: stack::Stack {
|
impl<'a, Stack> Context<'a, Stack> where Stack: stack::Stack {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn new<F>(mut stack: Stack, f: F) -> Context<Stack>
|
pub unsafe fn new<F>(mut stack: Stack, f: F) -> Context<'a, Stack>
|
||||||
where F: FnOnce() + Send + 'static {
|
where F: FnOnce() + Send + 'a {
|
||||||
let stack_id = StackId::register(&mut stack);
|
let stack_id = StackId::register(&mut stack);
|
||||||
let regs = Registers::new(&mut stack, f);
|
let regs = Registers::new(&mut stack, f);
|
||||||
Context {
|
Context {
|
||||||
regs: regs,
|
regs: regs,
|
||||||
_stack_id: stack_id,
|
_stack_id: stack_id,
|
||||||
stack: stack
|
stack: stack,
|
||||||
|
_ref: PhantomData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue