You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::sync::mpsc::channel;use std::time::Duration;use std::thread;fncalculate_data() -> u32{5}fnsave_data(data:&u32){
thread::sleep(Duration::from_secs(1));println!("Saving data: {}", data);}fnmain(){let(sender, receiver) = channel();let save = thread::spawn(move|| {let data = calculate_data();//Run calculation
sender.send(data).unwrap();//Send result to main threadsave_data(&data);//Save data to disk in current thread});//data is now available in main threadprintln!("{:?}", receiver.recv().unwrap());
save.join().unwrap();//Blocks until data is written.println!("done");}
Since we have
w_store
persistent, we can send of the file writes to a future or rayon thread.The text was updated successfully, but these errors were encountered: