Chatterino / chatterino2

Chat client for https://twitch.tv
MIT License
2.06k stars 449 forks source link

chore: use condition variable to shutdown websocket pools #5721

Closed Nerixyz closed 2 days ago

Nerixyz commented 2 days ago

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.