On 08/11/2013 12:15 PM, Matthieu Monrocq wrote:
Hi Corey,
It's great to see that people are thinking more and more about
integrating Rust in existing languages!
I wonder however whether the other alternative has been envisioned: if
Rust requires a runtime to work properly (specifically: TLS, task
failure), would it be possible to provide an external caller the
ability to setup the runtime before calling Rust methods ?
Yes, this is absolutely a requirement for embedding Rust. Servo needs it
so it will happen. Specifically, in order to do any useful embedding you
need to be able to communicate from outside a task to inside and vice
versa. What I am expecting here is to provide a `Task` subclass like
`ThreadTask` or `StackTask` (a task that isn't a green thread and runs
on the local thread's stack) that provides most of the task-local
functionality without the user-space context switching. In an FFI
callback from another language you might do something vaguely like
extern fn callback(cbdata: *Void) {
let data = from_cbdata(cbdata);
do in_stack_task {
// Send a message to a normal Rust task
data.chan.send(GoDoSomethingInARustTask);
}
}
I haven't put any work into this because there are so many other things
I need to do, but this is the gist of what I have in mind.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev