std::thread
has its own swap
method. I've been successful swapping running (non-joinable) threads even though you can't move-assign runnable threads.
So am I benefiting from some undocumented feature of the C++ implementation I'm using or is it actually guaranteed that std::thread::swap
works on joinable threads (i.e., it must not use move-assignment)?
cppreference(, my goto site for C++ information,) only says it "swaps the underlying pointers" but that statement doesn't to me mean much since, really, I don't care (and shouldn't have to) about the underlying implementation of std::thread
and also because it doesn't explicitly say either "without using move-assignment" or "even if the threads are not joinable".
(I know the fact that std::thread
has it's own swap suggests there's a specific reason for it but I don't know that that reason is to make is safe even though move-assign isn't...)
Aucun commentaire:
Enregistrer un commentaire