File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 69126912\rSec 3[intro.progress]{Forward progress}
69136913
69146914\pnum
6915- The implementation may assume that any thread will eventually do one of the
6916- following:
6915+ The implementation may assume\ubdef {intro.progress.stops} that any thread
6916+ will eventually do one of the following:
69176917\begin {itemize }
69186918\item terminate,
69196919\item invoke the function \tcode {std::this_thread::yield}\iref {thread.thread.this },
Original file line number Diff line number Diff line change 502502\end {codeblock }
503503\end {example }
504504
505+ \rsec 2[ub.intro.progress]{Forward progress}
506+
507+ \pnum
508+ \ubxref {intro.progress.stops } \\
509+
510+ The behavior is undefined if a thread of execution that has not terminated stops
511+ making execution steps.
512+
513+ \pnum
514+ \begin {example }
515+ \begin {codeblock }
516+ bool stop() { return false; }
517+
518+ void busy_wait_thread() {
519+ while (!stop()); // undefined behavior, thread makes no progress but the loop
520+ } // is not trivial because `stop()` is not a constant expression
521+
522+ int main() {
523+ std::thread t(busy_wait_thread);
524+ t.join();
525+ }
526+ \end {codeblock }
527+ \end {example }
505528
506529\rSec 2[ub.basic.start.main]{main function}
507530
You can’t perform that action at this time.
0 commit comments