Skip to content

Commit 4efc563

Browse files
committed
Assert non-zero parallel producer mininum length to avoid splittinf off empty tasks.
1 parent f71ec6b commit 4efc563

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/parallel/par.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ macro_rules! par_iter_view_wrapper {
160160
where D: Dimension,
161161
A: $($thread_bounds)*,
162162
{
163-
/// Sets the minimum number of elements desired to process in each job. This will not be split any smaller than this length, but of course a producer could already be smaller to begin with.
163+
/// Sets the minimum number of elements desired to process in each job. This will not be
164+
/// split any smaller than this length, but of course a producer could already be smaller
165+
/// to begin with.
166+
///
167+
/// ***Panics*** if `min_len` is zero.
164168
pub fn with_min_len(self, min_len: usize) -> Self {
169+
assert_ne!(min_len, 0, "Minimum number of elements must at least be one to avoid splitting off empty tasks.");
170+
165171
Self {
166172
min_len,
167173
..self
@@ -306,8 +312,14 @@ impl<D, Parts> Parallel<Zip<Parts, D>>
306312
where
307313
D: Dimension,
308314
{
309-
/// Sets the minimum number of elements desired to process in each job. This will not be split any smaller than this length, but of course a producer could already be smaller to begin with.
315+
/// Sets the minimum number of elements desired to process in each job. This will not be
316+
/// split any smaller than this length, but of course a producer could already be smaller
317+
/// to begin with.
318+
///
319+
/// ***Panics*** if `min_len` is zero.
310320
pub fn with_min_len(self, min_len: usize) -> Self {
321+
assert_ne!(min_len, 0, "Minimum number of elements must at least be one to avoid splitting off empty tasks.");
322+
311323
Self {
312324
min_len,
313325
..self

0 commit comments

Comments
 (0)