forked from M-Labs/libfringe
b8211689fa
fix #7
22 lines
443 B
Rust
22 lines
443 B
Rust
#![feature(thread_local)]
|
|
extern crate lwkt;
|
|
use lwkt::{Context, StackSource};
|
|
|
|
#[thread_local]
|
|
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 mut ctx = Context::new(stack, move || {
|
|
println!("it's alive!");
|
|
(*ctx_slot).swap();
|
|
});
|
|
|
|
ctx_slot = &mut ctx;
|
|
|
|
(*ctx_slot).swap();
|
|
}
|
|
}
|