Skip to content

Commit c0734b5

Browse files
committed
expose worker guards
1 parent b3eb77c commit c0734b5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

communication/src/initialize.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Configuration {
5353

5454
opts
5555
}
56-
56+
5757
/// Constructs a new configuration by parsing supplied text arguments.
5858
///
5959
/// Most commonly, this uses `std::env::Args()` as the supplied iterator.
@@ -281,11 +281,21 @@ pub struct WorkerGuards<T:Send+'static> {
281281
}
282282

283283
impl<T:Send+'static> WorkerGuards<T> {
284+
285+
/// Returns the number of guards.
286+
pub fn len(&self) -> usize { self.guards.len() }
287+
288+
/// Returns a reference to the indexed guard.
289+
pub fn guard(&self, index: usize) -> &std::thread::JoinHandle<T> {
290+
&self.guards[index]
291+
}
292+
284293
/// Waits on the worker threads and returns the results they produce.
285294
pub fn join(mut self) -> Vec<Result<T, String>> {
286-
self.guards.drain(..)
287-
.map(|guard| guard.join().map_err(|e| format!("{:?}", e)))
288-
.collect()
295+
self.guards
296+
.drain(..)
297+
.map(|guard| guard.join().map_err(|e| format!("{:?}", e)))
298+
.collect()
289299
}
290300
}
291301

0 commit comments

Comments
 (0)