News for hackers. Stuff that matters.
Re:An Improved Thread with C++20 by AnimalMuppet on Monday February 15, 2021 @12:48PM (#26145083)
Then what was lrossi referring to when he (?) said:

>>> The ability to pause a thread from outside is interesting, but it doesn’t seem very useful in general.

>>> It also comes with risks. What if it’s holding a lock? That could cause a performance/latency disaster.

Which you replied to, not claiming that it couldn't be paused from outside, but instead that the lock risk was just the same as returning from a function.

Re:An Improved Thread with C++20 by jeffbee on Monday February 15, 2021 @12:53PM (#26145136)
It's difficult to get the point across on the Internet, but lrossi's statement is just nonsense. std::jthread has not introduced any new risks with respect to locking.
Re:An Improved Thread with C++20 by lrossi on Monday February 15, 2021 @03:04PM (#26146641)
You are right, the sleep functions apply only to “this_thread”. What confused me is the comment for the two functions, which refer to the thread as “t” and not “this_thread”; which also matches the naming used for the “is_joinable” function, where it is not the current thread.

So I thought it’s a way to do back pressure across threads, which could be useful, but I was clearly wrong. My bad, but also not a great choice of naming things in the original article.

Then again, if you can only put the current thread to sleep, why have a function for it? Why not call sleep directly?