no explicit drop
This commit is contained in:
parent
d02b6375c6
commit
e92a3afe9f
1 changed files with 2 additions and 5 deletions
|
|
@ -50,7 +50,7 @@ impl From<String> for RubyScript {
|
||||||
type RubyClosure = Box<dyn FnOnce(Ruby) + Send>;
|
type RubyClosure = Box<dyn FnOnce(Ruby) + Send>;
|
||||||
|
|
||||||
struct RubyThread {
|
struct RubyThread {
|
||||||
sender: Option<crossbeam_channel::Sender<RubyClosure>>,
|
sender: crossbeam_channel::Sender<RubyClosure>,
|
||||||
handle: Option<JoinHandle<()>>,
|
handle: Option<JoinHandle<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ impl RubyThread {
|
||||||
});
|
});
|
||||||
|
|
||||||
RubyThread {
|
RubyThread {
|
||||||
sender: Some(sender),
|
sender,
|
||||||
handle: Some(handle),
|
handle: Some(handle),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -78,8 +78,6 @@ impl RubyThread {
|
||||||
fn execute<T: Send + 'static>(&self, f: Box<dyn FnOnce(Ruby) -> T + Send>) -> T {
|
fn execute<T: Send + 'static>(&self, f: Box<dyn FnOnce(Ruby) -> T + Send>) -> T {
|
||||||
let (return_sender, return_receiver) = crossbeam_channel::bounded(0);
|
let (return_sender, return_receiver) = crossbeam_channel::bounded(0);
|
||||||
self.sender
|
self.sender
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.send(Box::new(move |ruby| {
|
.send(Box::new(move |ruby| {
|
||||||
return_sender.send(f(ruby)).unwrap();
|
return_sender.send(f(ruby)).unwrap();
|
||||||
}))
|
}))
|
||||||
|
|
@ -90,7 +88,6 @@ impl RubyThread {
|
||||||
|
|
||||||
impl Drop for RubyThread {
|
impl Drop for RubyThread {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
drop(self.sender.take().unwrap());
|
|
||||||
let handle = self.handle.take().unwrap();
|
let handle = self.handle.take().unwrap();
|
||||||
handle.join().unwrap();
|
handle.join().unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue