pub fn sync<I, T>(jobs: I) -> Vec<JobResult<T>> ⓘExpand description
Waits for all jobs to complete and returns their thread::Results.
Normally you would use the sync! macro instead of using this function directly.
This function blocks the current thread until all jobs have completed.
It then collects and returns their results in a vector.
§Examples
use versust::sync;
use std::thread;
use std::time::Duration;
let results = sync([
versust::into_job(|| {
thread::sleep(Duration::from_millis(100));
1
}),
versust::into_job(|| {
thread::sleep(Duration::from_millis(50));
2
})
]);
let results: Vec<_> = results.into_iter().map(|h| h.unwrap()).collect();
assert_eq!(results, vec![1, 2]);