sync: bounded channel can not have 0 size (#879)

This commit is contained in:
Stephen Carman
2019-02-01 12:54:06 -08:00
committed by Carl Lerche
parent e1a07ce50c
commit 95b0eec8af
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -111,6 +111,7 @@ pub struct RecvError(());
/// }));
/// ```
pub fn channel<T>(buffer: usize) -> (Sender<T>, Receiver<T>) {
assert_eq!(buffer >= 1, true);
let semaphore = (::semaphore::Semaphore::new(buffer), buffer);
let (tx, rx) = chan::channel(semaphore);