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