add return value to compute_async
This commit is contained in:
@@ -9,14 +9,14 @@ use std::time::Instant;
|
||||
|
||||
const USER_NAME: &str = "Jonah";
|
||||
|
||||
pub fn compute_async<T: Display + Send + 'static>(mut function: impl FnMut(Sender<(T, T)>) + Send + 'static) {
|
||||
pub fn compute_async<T: Display + Send + 'static, R: Send + 'static>(mut function: impl FnMut(Sender<(T, T)>) -> R + Send + 'static ) -> R {
|
||||
let (tx, jh1) = spawn_submission_thread();
|
||||
let jh2 = thread::spawn(move || {
|
||||
function(tx);
|
||||
function(tx)
|
||||
});
|
||||
|
||||
jh1.join().unwrap();
|
||||
jh2.join().unwrap();
|
||||
jh2.join().unwrap()
|
||||
}
|
||||
|
||||
pub fn spawn_submission_thread<T: Display + Send + 'static>() -> (Sender<(T, T)>, JoinHandle<()>) {
|
||||
|
Reference in New Issue
Block a user