Skip to content

Commit 505823f

Browse files
committed
Add example with jthread.
1 parent 1aeb480 commit 505823f

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

talk/concurrency/threadsasync.tex

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,34 @@
1010
\item \cpp20: \mintinline{cpp}{std::jthread} automatically joins at destruction
1111
\end{itemize}
1212
\end{block}
13-
\pause
14-
\begin{exampleblock}{Example code}
15-
\begin{cppcode*}{}
16-
void foo() {...}
17-
void bar() {...}
18-
int main() {
19-
std::thread t1{foo};
20-
std::thread t2{bar};
21-
for (auto t: {&t1,&t2}) t->join();
22-
}
23-
\end{cppcode*}
24-
\end{exampleblock}
13+
\vspace{-1\baselineskip}
14+
\begin{overprint}
15+
\onslide<1>
16+
\begin{exampleblock}{Example code}
17+
\begin{cppcode*}{gobble=2}
18+
void foo() {...}
19+
void bar() {...}
20+
int main() {
21+
std::thread t1{foo};
22+
std::thread t2{bar};
23+
for (auto t: {&t1,&t2}) t->join();
24+
return 0;
25+
}
26+
\end{cppcode*}
27+
\end{exampleblock}
28+
\onslide<2>
29+
\begin{exampleblock}{Example with jthread (\cpp20)}
30+
\begin{cppcode*}{gobble=2}
31+
void foo() {...}
32+
void bar() {...}
33+
int main() {
34+
std::jthread t1{foo};
35+
std::jthread t2{bar};
36+
return 0;
37+
}
38+
\end{cppcode*}
39+
\end{exampleblock}
40+
\end{overprint}
2541
\end{frame}
2642

2743
\begin{frame}[fragile]

0 commit comments

Comments
 (0)