I try to pass the problem into a function a couple of times spawn(to create a new thread / task) and tell the compiler error: cannot capture variable of type "blah blah", which does not fulfill "Send", in a bounded closure.
Is there a way to convert a type capable of doing Submit, or is it fixed based on some set of rules?
For example, I can easily implement a trait ToStrusing the following directive:
#[deriving(ToStr, Rand)]
struct Point {
x: int,
y: int,
}
Can I do something similar for hell Send? Or are "good" traits handled differently?
Here is a concrete example of this problem - is there a way to overcome it?
fn create_process_options(cmdinfo: &CmdInfo) -> (ProcessOptions, Option<FileDesc>) {
// ... omitted
}
// "po" is of type std::run::ProcessOptions
let (po, filedesc_opt) = create_process_options(&cmdinfo);
spawn(proc() {
let mut ps = Process::new(cmdinfo.program, cmdinfo.args, po).expect("darn");
ps.finish();
});
Compiler Error:
error: cannot capture variable of type `std::run::ProcessOptions<>`, which does not fulfill `Send`, in a bounded closure
let mut process = Process::new(cmdinfo.program, cmdinfo.args, po).expect("darn");
^~
note: this closure environment must satisfy `Send`
let mut process = Process::new(cmdinfo.program, cmdinfo.args, po).expect("darn");
source
share