let StackSource::get_stack take &mut self
This commit is contained in:
parent
9bb0ce483d
commit
bdb6e0bd8b
@ -10,7 +10,7 @@ static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<
|
||||
#[bench]
|
||||
fn swap(b: &mut test::Bencher) {
|
||||
unsafe {
|
||||
let stack = lwkt::os::StackSource::get_stack(4 << 20).unwrap();
|
||||
let stack = lwkt::os::StackSource.get_stack(4 << 20).unwrap();
|
||||
|
||||
let mut ctx = Context::new(stack, move || {
|
||||
let ctx_ptr = ctx_slot;
|
||||
|
@ -7,7 +7,7 @@ static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context<
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let stack = lwkt::os::StackSource::get_stack(4 << 20).unwrap();
|
||||
let stack = lwkt::os::StackSource.get_stack(4 << 20).unwrap();
|
||||
|
||||
let mut ctx = Context::new(stack, move || {
|
||||
println!("it's alive!");
|
||||
|
@ -30,7 +30,7 @@ impl stack::StackSource for StackSource {
|
||||
type Output = Stack;
|
||||
type Error = IoError;
|
||||
|
||||
fn get_stack(size: usize) -> Result<Stack, IoError> {
|
||||
fn get_stack(&mut self, size: usize) -> Result<Stack, IoError> {
|
||||
let page_size = sys::page_size();
|
||||
|
||||
// round the page size up,
|
||||
|
@ -20,5 +20,5 @@ pub trait Stack {
|
||||
pub trait StackSource {
|
||||
type Output: Stack;
|
||||
type Error: Debug + Display = ();
|
||||
fn get_stack(size: usize) -> Result<Self::Output, Self::Error>;
|
||||
fn get_stack(&mut self, size: usize) -> Result<Self::Output, Self::Error>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user