Last active
August 29, 2015 13:56
-
-
Save arturoc/9090369 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spawn(proc(){ | |
let (port,chan): (comm::Port<Message>, comm::Chan<Message>) = comm::Chan::new(); | |
let mut chan = ~chan; | |
set_c_callback(c_callback, cast::transmute(&mut *chan)); | |
loop{ | |
//... | |
} | |
}); | |
extern "C" fn c_callback (data: *c_void){ | |
unsafe{ | |
let channel = data as *mut comm::Chan<Message>; | |
(*channel).send(MessageType); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment