parametrise Context on Stack
This commit is contained in:
parent
8dc53c3125
commit
54b34383e3
|
@ -3,7 +3,7 @@ extern crate test;
|
|||
extern crate lwkt;
|
||||
use lwkt::{Context, StackSource};
|
||||
|
||||
static mut ctx_slot: *mut Context = 0 as *mut Context;
|
||||
static mut ctx_slot: *mut Context<lwkt::os::Stack> = 0 as *mut Context<_>;
|
||||
|
||||
#[bench]
|
||||
fn context_new(b: &mut test::Bencher) {
|
||||
|
|
|
@ -3,7 +3,7 @@ extern crate test;
|
|||
extern crate lwkt;
|
||||
use lwkt::{Context, StackSource};
|
||||
|
||||
static mut ctx_slot: *mut Context = 0 as *mut Context;
|
||||
static mut ctx_slot: *mut Context<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 = 0 as *mut Context;
|
||||
static mut ctx_slot: *mut Context<lwkt::os::Stack> = 0 as *mut Context<_>;
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
use core::prelude::*;
|
||||
use arch::Registers;
|
||||
use os;
|
||||
use stack;
|
||||
|
||||
pub struct Context {
|
||||
pub struct Context<Stack: stack::Stack> {
|
||||
regs: Registers,
|
||||
_stack: os::Stack
|
||||
_stack: Stack
|
||||
}
|
||||
|
||||
impl Context {
|
||||
impl<Stack> Context<Stack> where Stack: stack::Stack {
|
||||
#[inline]
|
||||
pub unsafe fn new<F>(mut stack: os::Stack, f: F) -> Context where F: FnOnce() + Send + 'static {
|
||||
pub unsafe fn new<F>(mut stack: Stack, f: F) -> Context<Stack>
|
||||
where F: FnOnce() + Send + 'static {
|
||||
let regs = Registers::new(&mut stack, f);
|
||||
Context {
|
||||
regs: regs,
|
||||
|
|
Loading…
Reference in New Issue