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

chore: use condition variable to shutdown websocket pools #5721

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Nov 20, 2024

We don't need to spawn a new thread to wait on another thread to shut down. We can use a condition variable to synchronize the threads. (Conceptually), the exiting thread sets the variable and the parent waits on that event.
I abstracted that into a OnceFlag (better names are welcome). It's a flag that can be set and waited on. The tests involve some timing measurements because we want to wait for some time and "not wait for some time" when the flag is already set.

@Nerixyz Nerixyz force-pushed the chore/eradicate-std-async branch from 8b36069 to c995c97 Compare November 20, 2024 20:20
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

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

Looks good, qScopeGuard usage looks good too 👍 Merging in to get a bit of broader testing asap

@pajlada pajlada merged commit 1c827f6 into Chatterino:master Nov 20, 2024
18 checks passed
@Nerixyz Nerixyz deleted the chore/eradicate-std-async branch November 20, 2024 21:30
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