libfringe/examples/basic.rs

22 lines
425 B
Rust
Raw Normal View History

#![feature(thread_local)]
2014-12-23 11:24:40 +08:00
extern crate lwkt;
use lwkt::{Context, StackSource};
2014-12-23 11:24:40 +08:00
#[thread_local]
2015-04-16 04:26:51 +08:00
static mut ctx_slot: *mut Context<lwkt::os::Stack> = 0 as *mut Context<_>;
2014-12-23 11:24:40 +08:00
fn main() {
unsafe {
let stack = lwkt::os::StackSource::get_stack(4 << 20);
let mut ctx = Context::new(stack, move || {
println!("it's alive!");
(*ctx_slot).swap();
});
2014-12-23 11:24:40 +08:00
ctx_slot = &mut ctx;
2014-12-23 11:24:40 +08:00
(*ctx_slot).swap();
2014-12-23 11:24:40 +08:00
}
}