This commit is contained in:
Jaroslaw Konik 2025-05-10 16:35:31 +02:00
parent 0a9dc09b0c
commit 253761c730

View file

@ -74,19 +74,16 @@ impl RubyThread {
}
}
fn execute_in(&self, f: Box<dyn FnOnce(Ruby) -> RubyValue + Send>) -> RubyValue {
fn execute_in<T: Send + 'static>(&self, f: Box<dyn FnOnce(Ruby) -> T + Send>) -> T {
let (return_sender, return_receiver) = crossbeam_channel::bounded(0);
self.sender
.as_ref()
.unwrap()
.send(Box::new(move |ruby| {
return_sender.send(f(ruby)).unwrap();
// return_sender.send(f(ruby)).unwrap();
// drop(return_sender);
}))
.unwrap();
return_receiver.recv().unwrap();
RubyValue(())
return_receiver.recv().unwrap()
}
}
@ -125,7 +122,7 @@ impl Runtime for RubyRuntime {
}
fn with_engine<T>(&self, f: impl FnOnce(&Self::RawEngine) -> T) -> T {
todo!()
RUBY_THREAD.execute_in(Box::new(move |ruby| f(&ruby)))
}
fn eval(