2015-01-14 15:31:17 +08:00
|
|
|
#![feature(thread_local)]
|
2014-12-23 11:24:40 +08:00
|
|
|
extern crate lwkt;
|
|
|
|
use lwkt::Context;
|
|
|
|
|
2015-01-14 15:31:17 +08:00
|
|
|
#[thread_local]
|
|
|
|
static mut ctx_slot: *mut Context = 0 as *mut Context;
|
2014-12-23 11:24:40 +08:00
|
|
|
|
2015-01-14 15:31:17 +08:00
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
let mut ctx = Context::new(move |:| {
|
|
|
|
println!("it's alive!");
|
|
|
|
(*ctx_slot).swap();
|
|
|
|
});
|
2014-12-23 11:24:40 +08:00
|
|
|
|
2015-01-14 15:31:17 +08:00
|
|
|
ctx_slot = &mut ctx;
|
2014-12-23 11:24:40 +08:00
|
|
|
|
2015-01-14 15:31:17 +08:00
|
|
|
(*ctx_slot).swap();
|
2014-12-23 11:24:40 +08:00
|
|
|
}
|
|
|
|
}
|