2 ms·
> The caller cannot assume that the thread will join on destruction and needs to conservatively join or detach explicitly anyway. This seems a little backwards
by dataflow 6y ago
> The caller cannot assume that the thread will join on destruction and needs to conservatively join or detach explicitly anyway.
This seems a little backwards to me? If the thread should join on destruction then that flag should be set. If not then it should be clear. I'd argue that flag should probably be set in general (and it seems you might feel the same way), but if you have a reason to clear it, then you're just fighting your own program by ignoring it.
> Re container, they will only be instantiated twice if you actually use both std::jthread and std::thread of course. The idea (which I disagree) is that jthread is the better solution and std::thread is sort of deprecated.
Good point!
- gpderetta 6y agothe function that will be affected by the thread blocking might not be the one that has created the thread so it might not have a chance to set the flag. Of course you can handle it by declaring and documenting preconditions and so on, but, when possible, enforcing these sort of things at the type level is better.