Now that scoped threads are stable in std
, should I reach for these in the first instance, or are there reasons to prefer those provided by crossbeam
?
No, in fact, as far as I’m aware, the std
implementation should be better (more lightweight) since it can use some internals of how std::thread
works. Also, it managed to come with a (usable) API where you don’t have to pass the scope into spawned threads via closure arguments, i.e. s.spawn(|s| /* use `s` here, too */)
(crossbeam) vs s.spawn(|| /* use `s` here, too */)
(std); and in particular s.spawn(|_| /* I don't even need `s` here */)
(crossbeam) vs s.spawn(|| /* I don't even need `s` here */)
(std)
FWIW, I've had a much better experience with rayon::scope
(and more generally rayon::ThreadPool::scope
) than with either crossbeam
directly or the "new" std::thread::scope
.
It's a larger dependency for sure.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.