Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly allow ThreadPool to be started multiple times. #1572

Merged
merged 1 commit into from Jun 25, 2020

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Jun 25, 2020

Motivation:

Our API documentation claims that NIOThreadPool.start() will tolerate
being called multiple times. However, this wasn't actually true: in
debug mode it'd hit an assertion, and in release mode it would quietly
orphan all its threads and replace them with new ones, leaving there
with twice as many threads and some that wouldn't be closed down.

We should support the functionality we claim we do.

Modifications:

  • Fixed the incorrect check for running thread pool state.
  • Added a test to validate we actually allow multiple starts.

Result:

Thread pools really can be started multiple times.

Motivation:

Our API documentation claims that NIOThreadPool.start() will tolerate
being called multiple times. However, this wasn't actually true: in
debug mode it'd hit an assertion, and in release mode it would quietly
orphan all its threads and replace them with new ones, leaving there
with twice as many threads and some that wouldn't be closed down.

We should support the functionality we claim we do.

Modifications:

- Fixed the incorrect check for running thread pool state.
- Added a test to validate we actually allow multiple starts.

Result:

Thread pools really can be started multiple times.
@Lukasa Lukasa added the patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Jun 25, 2020
@Lukasa Lukasa added this to the 2.19.0 milestone Jun 25, 2020
@Lukasa Lukasa requested a review from weissi June 25, 2020 09:29
Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

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

Thank you!

@glbrntt glbrntt merged commit 30961d2 into apple:master Jun 25, 2020
slashmo pushed a commit to slashmo/swift-nio that referenced this pull request Aug 18, 2020
Motivation:

Our API documentation claims that NIOThreadPool.start() will tolerate
being called multiple times. However, this wasn't actually true: in
debug mode it'd hit an assertion, and in release mode it would quietly
orphan all its threads and replace them with new ones, leaving there
with twice as many threads and some that wouldn't be closed down.

We should support the functionality we claim we do.

Modifications:

- Fixed the incorrect check for running thread pool state.
- Added a test to validate we actually allow multiple starts.

Result:

Thread pools really can be started multiple times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider allowing call to NIOThreadPool.start() while pool is already running
3 participants