Skip to content

Conversation

@davidlattimore
Copy link
Contributor

No description provided.

@davidlattimore
Copy link
Contributor Author

This fixes two different deadlocks when downsizing. The first, was that the heartbeat thread wouldn't shut down because we tried to join the heartbeath thread while still holding the lock on the threadpool's state mutex, which the heartbeat thread also needed to lock before it could know to shut down.

The second deadlock was that the worker threads weren't being woken up, so didn't know that they needed to shut down.

There are existing tests that were hitting these deadlocks. e.g. thread_pool::tests::join_basic now passes, where before it ran indefinitely.

Issue #37

Copy link
Owner

@NthTensor NthTensor left a comment

Choose a reason for hiding this comment

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

This looks good, thanks for the contribution! And sorry for the slight delay, I had taken a brief hiatus from working on this.

This fix is quite similar to some changes I have locally. Actually I have built up a bit of a backlog of local changes and fixes -- this was probably fine during the R&D phase, but if people like you are actually evaluating the library I guess I need to be a bit more proactive in publishing my work.

@NthTensor NthTensor merged commit e4a9bc2 into NthTensor:main Dec 26, 2025
4 checks passed
@NthTensor NthTensor mentioned this pull request Dec 26, 2025
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.

2 participants