Skip to content

Instantly share code, notes, and snippets.

@tobz
Created April 4, 2018 18:21
Show Gist options
  • Save tobz/dcf3f30ee3d36037b1686059f9faf3dc to your computer and use it in GitHub Desktop.
Save tobz/dcf3f30ee3d36037b1686059f9faf3dc to your computer and use it in GitHub Desktop.
error[E0382]: use of moved value: `tx`
--> src/main.rs:77:21
|
77 | tx.send(()).unwrap();
| ^^ value moved here in previous iteration of loop
|
= note: move occurs because `tx` has type `futures::Sender<()>`, which does not implement the `Copy` trait
let signals = chan_signal::notify(&[Signal::USR1, Signal::USR2]);
let (signal_tx, signal_rx) = oneshot::channel::<()>();
thread::spawn(move || {
let tx = signal_tx;
loop {
let signal = signals.recv().unwrap();
debug!("[core] signal received: {:?}", signal);
match signal {
Signal::USR1 => {
// signal to spawn new process
},
Signal::USR2 => {
// signal to close this process
tx.send(()).unwrap();
},
_ => {
// we don't care about the rest
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment