Skip to content

feat: require NonZeroUsize parallelism limits - #5

Merged
hawkw merged 3 commits into
eliza/into-panicfrom
eliza/nonzero
Dec 1, 2026
Merged

hawkw merged 3 commits into
eliza/into-panicfrom
eliza/nonzero

Conversation

@hawkw

@hawkw hawkw commented Nov 27, 2026

Copy link
Copy Markdown
Member

If the parallelism limit is set to 0, then all calls to ParallelTaskSet::spawn will just hang forever. There is basically no situation in which anyone would want that, so we should probably not let you do it.

This commit changes the parallelism limit to be a NonZeroUsize, which stops you from doing that at the cost of making it slightly more annoying to construct.

Fixes #2

@hawkw
hawkw requested review from iliana and smklein November 27, 2026 23:38
@hawkw
hawkw added this pull request to stack #4 November 27, 2026 23:38
@hawkw
hawkw enabled stacked auto-merge (squash) November 27, 2026 23:46
Comment thread src/lib.rs Outdated
Comment on lines +288 to +296
/// Returns the number of tasks currently in this set.
pub fn len(&self) -> usize {
self.set.len()
}

/// Returns `true` if this set is currently empty.
pub fn is_empty(&self) -> bool {
self.set.is_empty()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm looks like this might have bled out of #6, which appears to be empty?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gack

stacked auto-merge was automatically disabled November 30, 2026 23:21

Auto-merge was disabled for another pull request in the stack

If the parallelism limit is set to 0, then all calls to
`ParallelTaskSet::spawn` will just hang forever. There is basically no
situation in which anyone would want that, so we should probably not let
you do it.

This commit changes the parallelism limit to be a `NonZeroUsize`, which
stops you from doing that at the cost of making it slightly more
annoying to construct.

Fixes #2
@hawkw
hawkw enabled stacked auto-merge (squash) November 30, 2026 23:50
@hawkw
hawkw merged commit 33718cd into main Dec 1, 2026
5 checks passed
@hawkw
hawkw deleted the eliza/nonzero branch December 1, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nothing stops you from setting a parallelism limit limit of zero, which will make spawn hang

2 participants