libfringe/src/context.rs

25 lines
431 B
Rust
Raw Normal View History

use core::prelude::*;
use arch::Registers;
2015-04-16 04:20:28 +08:00
use os;
2014-12-24 13:12:39 +08:00
2014-12-23 11:24:40 +08:00
pub struct Context {
regs: Registers,
2015-04-16 04:20:28 +08:00
_stack: os::Stack
2014-12-23 11:24:40 +08:00
}
impl Context {
#[inline]
pub unsafe fn new<F>(mut stack: os::Stack, f: F) -> Context where F: FnOnce() + Send + 'static {
let regs = Registers::new(&mut stack, f);
2014-12-23 11:24:40 +08:00
Context {
regs: regs,
_stack: stack
2014-12-23 11:24:40 +08:00
}
}
#[inline(always)]
pub unsafe fn swap(&mut self) {
self.regs.swap()
2014-12-23 11:24:40 +08:00
}
}