Skip to content

Commit 54b3438

Browse files
committed
parametrise Context on Stack
1 parent 8dc53c3 commit 54b3438

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

benches/context_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate test;
33
extern crate lwkt;
44
use lwkt::{Context, StackSource};
55

6-
static mut ctx_slot: *mut Context = 0 as *mut Context;
6+
static mut ctx_slot: *mut Context<lwkt::os::Stack> = 0 as *mut Context<_>;
77

88
#[bench]
99
fn context_new(b: &mut test::Bencher) {

benches/swap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate test;
33
extern crate lwkt;
44
use lwkt::{Context, StackSource};
55

6-
static mut ctx_slot: *mut Context = 0 as *mut Context;
6+
static mut ctx_slot: *mut Context<lwkt::os::Stack> = 0 as *mut Context<_>;
77

88
#[bench]
99
fn swap(b: &mut test::Bencher) {

examples/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate lwkt;
33
use lwkt::{Context, StackSource};
44

55
#[thread_local]
6-
static mut ctx_slot: *mut Context = 0 as *mut Context;
6+
static mut ctx_slot: *mut Context<lwkt::os::Stack> = 0 as *mut Context<_>;
77

88
fn main() {
99
unsafe {

src/context.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
use core::prelude::*;
22
use arch::Registers;
3-
use os;
3+
use stack;
44

5-
pub struct Context {
5+
pub struct Context<Stack: stack::Stack> {
66
regs: Registers,
7-
_stack: os::Stack
7+
_stack: Stack
88
}
99

10-
impl Context {
10+
impl<Stack> Context<Stack> where Stack: stack::Stack {
1111
#[inline]
12-
pub unsafe fn new<F>(mut stack: os::Stack, f: F) -> Context where F: FnOnce() + Send + 'static {
12+
pub unsafe fn new<F>(mut stack: Stack, f: F) -> Context<Stack>
13+
where F: FnOnce() + Send + 'static {
1314
let regs = Registers::new(&mut stack, f);
1415
Context {
1516
regs: regs,

0 commit comments

Comments
 (0)