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

Simplify the qmlextensionplugins example a bit #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lu-fennell
Copy link
Contributor

... by using a channel to shut down the timer thread, instead of a
condvar.

I was a little distracted by the verbose handling of the condvar when looking at the example. This is my attempt to make it a bit clearer. Maybe you like it.

... by using a channel to shut down the timer thread, instead of a
condvar.
@lu-fennell
Copy link
Contributor Author

Note: I used the channel from std::sync::mpsc which I guess is not really recommended, as it seem to have bugs. So maybe it's better to switch to crossbeam's channel.

@ogoffart
Copy link
Member

ogoffart commented Nov 9, 2021

To me, the two are equal in term of complexity. Although yours has less lines of code.

I wouldn't want to pull a crossbeam dependency just for that.

Anyway, the change looks good to me.

@ratijas what's your opinion?

@lu-fennell
Copy link
Contributor Author

To me, the two are equal in term of complexity.

Fair enough :)

Fwiw, I, personally, find that the channel version has less subtleties to be aware of. In particular, it took me a little while to realize (resp. read up on) the interaction between condvars and mutexes and why spurious wake-ups aren't a problem here. But that's just me, I guess.

Anyhow, in case you prefer the original condvar version, it would be good to replace thread: Option<(JoinHandle<()>, Arc<AbortCondVar>)> with thread: Option<Arc<AbortCondVar>>; the JoinHandle<()> part is never used...

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