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