Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![cfg_attr(test, deny(warnings))]
#![deny(missing_docs)]

//! # scoped-pool
Expand Down Expand Up @@ -322,7 +321,7 @@ impl<'scope> Scope<'scope> {
pub fn zoom<'smaller, F, R>(&self, scheduler: F) -> R
where F: FnOnce(&Scope<'smaller>) -> R,
'scope: 'smaller {
let scope = unsafe { self.refine::<'smaller>() };
let scope = unsafe { self.refine() };

// Join the scope either on completion of the scheduler or panic.
defer!(scope.join());
Expand Down Expand Up @@ -697,6 +696,22 @@ mod test {
});
}

#[test]
fn no_leak() {
let counters = ::std::sync::Arc::new(());

let mut pool = Pool::new(4);
pool.scoped(|scoped| {
let c = ::std::sync::Arc::clone(&counters);
scoped.execute(move || {
let _c = c;
::std::thread::sleep(::std::time::Duration::from_millis(100));
});
});
drop(pool);
assert_eq!(::std::sync::Arc::strong_count(&counters), 1);
}

#[test]
#[should_panic]
fn test_scheduler_panic_waits_for_tasks() {
Expand Down