Skip to content

Commit ea70162

Browse files
Minor slide improvements
1 parent 9d219a3 commit ea70162

File tree

20 files changed

+131
-122
lines changed

20 files changed

+131
-122
lines changed

talk/basicconcepts/arrayspointers.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@
7070

7171
\begin{frame}[fragile]
7272
\frametitlecpp[11]{nullptr}
73-
\begin{block}{Finally a \cpp~NULL pointer}
73+
\begin{block}{A pointer to nothing}
7474
\begin{itemize}
7575
\item if a pointer doesn't point to anything, set it to \mintinline{cpp}{nullptr}
76-
\item works like 0 or NULL in standard cases
77-
\item triggers compilation error when mapped to integer
76+
\item same as setting it to 0 or \mintinline{cpp}{NULL} (before \cpp11)
77+
\item triggers compilation error when assigned to integer
7878
\end{itemize}
7979
\end{block}
8080
\pause

talk/basicconcepts/classenum.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@
8686
\vfill \null
8787
\end{multicols}
8888
\onslide<7->{
89-
\begin{alertblock}{}
89+
\begin{exampleblock}{}
9090
Starting with \cpp17: prefer \mintinline{cpp}{std::variant}
91-
\end{alertblock}
91+
\end{exampleblock}
9292
}
9393
\end{frame}
9494

talk/concurrency/atomic.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@
6060
\begin{block}{Use built-in atomic functions}
6161
\begin{itemize}
6262
\item The built-in atomic functions are thread safe
63-
\item \texttt{fetch\_add} (\mintinline{cpp}{operator+=()}): atomically \{ load; add; store \}
63+
\item \mintinline{cpp}{fetch_add} and \mintinline{cpp}{operator+=}: atomic \{ load; add; store \}
6464
\item But don't confuse ``\mintinline{cpp}{a += 2}'' and ``\mintinline{cpp}{a + 2}''
6565
\end{itemize}
6666
\end{block}
6767
\begin{exampleblock}{}
6868
\begin{cppcode*}{}
6969
std::atomic<int> a{0};
7070
std::thread t1([&]{ a.fetch_add(2); });
71-
std::thread t2([&]{ a.fetch_add(2); });
71+
std::thread t2([&]{ a += 2; });
7272
\end{cppcode*}
7373
\end{exampleblock}
7474
\begin{block}{Sequence diagram}
@@ -79,7 +79,7 @@
7979
\umlobject[x=6]{Thread 2}
8080
\begin{umlcall}[op=fetch\_add]{Thread 1}{atomic}
8181
\end{umlcall}
82-
\begin{umlcall}[op=fetch\_add, dt=9]{Thread 2}{atomic}
82+
\begin{umlcall}[op=\texttt{+=}, dt=9]{Thread 2}{atomic}
8383
\end{umlcall}
8484
\end{umlseqdiag}
8585
\draw[-triangle 60](9,0) -- (9,-2) node[right, pos=0.5]{time};

talk/concurrency/condition.tex

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
\frametitlecpp[11]{Condition variables}
55
\begin{block}{Communicating thread dependencies}
66
\begin{itemize}
7-
\item \texttt{std::condition\_variable} from condition\_variable header
7+
\item \mintinline{cpp}{std::condition_variable} from \mintinline{cpp}{<condition_variable>} header
88
\item Allows for a thread to sleep (= conserve CPU time) until a given condition is satisfied
99
\end{itemize}
1010
\end{block}
1111
\pause
1212
\begin{block}{Usage}
1313
\begin{itemize}
1414
\item Use RAII-style locks to protect shared data
15-
\item wait() will block until the condition is met
15+
\item \mintinline{cpp}{wait()} will block until the condition is met
1616
\begin{itemize}
1717
\item you can have several waiters sharing the same mutex
1818
\end{itemize}
19-
\item notify\_one() will wake up one waiter
20-
\item notify\_all() will wake up all waiters
19+
\item \mintinline{cpp}{notify_one()} will wake up one waiter
20+
\item \mintinline{cpp}{notify_all()} will wake up all waiters
2121
\end{itemize}
2222
\end{block}
2323
\end{frame}
@@ -27,8 +27,8 @@
2727
\begin{block}{Producer side}
2828
\begin{itemize}
2929
\item Imagine multiple threads sharing data. Protect it with a mutex
30-
\item Use a \texttt{condition\_variable} to notify consumers
31-
\item Optimisation: Don't hold lock while notifying (would block the waking threads)
30+
\item Use a condition variable to notify consumers
31+
\item Optimization: Don't hold lock while notifying (would block the waking threads)
3232
\end{itemize}
3333
\end{block}
3434
\begin{exampleblock}{}
@@ -53,17 +53,17 @@
5353
\begin{block}{Consumer side I: Going into wait}
5454
\begin{itemize}
5555
\item Start many threads which have to wait for shared data
56-
\item Provide a lock to be managed by \texttt{wait}
57-
\item \texttt{wait} will only lock while necessary; unlocked while sleeping
58-
\item Threads might wake up, but \texttt{wait} returns only when condition satisfied
56+
\item Provide a lock to be managed by \mintinline{cpp}{wait}
57+
\item \mintinline{cpp}{wait} will only lock while necessary; unlocked while sleeping
58+
\item Threads might wake up, but \mintinline{cpp}{wait} returns only when condition satisfied
5959
\end{itemize}
6060
\end{block}
6161
\onslide<2->
6262
\begin{block}{Consumer side II: Waking up}
6363
\begin{itemize}
64-
\item \texttt{notify\_all()} is called, threads wake up
64+
\item \mintinline{cpp}{notify_all()} is called, threads wake up
6565
\item Threads try to acquire mutex, evaluate condition
66-
\item One thread succeeds to acquire mutex, exits from \texttt{wait}
66+
\item One thread succeeds to acquire mutex, exits from \mintinline{cpp}{wait}
6767
\item \alt<2>{ {\color{red} Problem}: Other threads still blocked!}{ {\color{green!80!black} Solution:} Put locking and waiting in a scope}
6868
\end{itemize}
6969
\end{block}

talk/concurrency/mutexes.tex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
\end{itemize}
3939
\end{block}
4040
\pause
41-
\begin{alertblock}{Is ++ operator atomic ?}
41+
\begin{alertblock}{Is \texttt{++} operator atomic ?}
4242
\pause
4343
Usually not. It behaves like :
4444
\begin{cppcode*}{}
@@ -92,7 +92,7 @@
9292
\pause
9393
\begin{block}{The objects}
9494
\begin{description}[labelwidth=1.8cm]
95-
\item[std::mutex] in the mutex header. \textbf{Mut}ual \textbf{ex}clusion
95+
\item[std::mutex] in the \mintinline{cpp}{mutex} header. \textbf{Mut}ual \textbf{ex}clusion
9696
\item[std::scoped\_lock] RAII to lock and unlock automatically
9797
\item[std::unique\_lock] same, but can be released/relocked explicitly
9898
\end{description}
@@ -114,9 +114,9 @@
114114
\frametitlecpp[17]{Mutexes and Locks}
115115
\begin{block}{Good practice}
116116
\begin{itemize}
117-
\item Generally use \texttt{scoped\_lock} (\cpp11: \texttt{lock\_guard})
118-
\item Hold as short as possible, wrap critical section in "\texttt{\string{ \string}}"
119-
\item Only if manual control needed, use \texttt{unique\_lock}
117+
\item Generally, use \mintinline{cpp}{std::scoped_lock}. Before \cpp17 use \mintinline{cpp}{std::lock_guard}.
118+
\item Hold as short as possible, consider wrapping critical section in block statement \mintinline{cpp}|{ }|
119+
\item Only if manual control needed, use \mintinline{cpp}{std::unique_lock}
120120
\end{itemize}
121121
\end{block}
122122
\begin{exampleblock}{}
@@ -187,7 +187,7 @@
187187
\item Respect a strict order in the locking across all threads
188188
\item Do not use locks
189189
\begin{itemize}
190-
\item Use other techniques, e.g. queues
190+
\item Use other techniques, e.g. lock-free queues
191191
\end{itemize}
192192
\end{itemize}
193193
\end{block}
@@ -197,9 +197,9 @@
197197
\frametitlecpp[17]{Shared mutex / locks}
198198
\begin{block}{Sharing a mutex}
199199
\begin{itemize}
200-
\item Normal \texttt{mutex} objects cannot be shared
201-
\item \texttt{shared\_mutex} to the rescue, but can be slower
202-
\item \textit{Either} exclusive \textit{or} shared locking; never both
200+
\item Normal \mintinline{cpp}{std::mutex} objects cannot be shared
201+
\item \mintinline{cpp}{std::shared_mutex} to the rescue, but can be slower
202+
\item \emph{Either} exclusive \emph{or} shared locking; never both
203203
\end{itemize}
204204
\end{block}
205205
\begin{exampleblock}{}

talk/concurrency/threadsasync.tex

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
\frametitlecpp[11]{Basic concurrency}
55
\begin{block}{Threading}
66
\begin{itemize}
7-
\item new object std::thread in \textless{}thread\textgreater{} header
7+
\item new object \mintinline{cpp}{std::thread} in \mintinline{cpp}{<thread>} header
88
\item takes a function as argument of its constructor
99
\item must be detached or joined before the main thread terminates
10-
\item \cpp20: std::jthread automatically joins at destruction
10+
\item \cpp20: \mintinline{cpp}{std::jthread} automatically joins at destruction
1111
\end{itemize}
1212
\end{block}
1313
\pause
1414
\begin{exampleblock}{Example code}
1515
\begin{cppcode*}{}
16-
void doSth() {...}
17-
void doSthElse() {...}
16+
void foo() {...}
17+
void bar() {...}
1818
int main() {
19-
std::thread t1(doSth);
20-
std::thread t2(doSthElse);
19+
std::thread t1(foo);
20+
std::thread t2(bar);
2121
for (auto t: {&t1,&t2}) t->join();
2222
}
2323
\end{cppcode*}
@@ -53,62 +53,60 @@
5353
\begin{block}{Concept}
5454
\begin{itemize}
5555
\item separation of the specification of what should be done and the retrieval of the results
56-
\item ``start working on this, and ping me when it's ready''
56+
\item ``start working on this, and let me check if it's done''
5757
\end{itemize}
5858
\end{block}
5959
\pause
6060
\begin{block}{Practically}
6161
\begin{itemize}
62-
\item std::async function launches an asynchronous task
63-
\item std::future template allows to handle the result
62+
\item \mintinline{cpp}{std::async} function launches an asynchronous task
63+
\item \mintinline{cpp}{std::future<T>} allows to retrieve the result
6464
\end{itemize}
6565
\end{block}
6666
\pause
6767
\begin{exampleblock}{Example code}
6868
\begin{cppcode*}{}
69-
int computeSth() {...}
70-
std::future<int> res = std::async(computeSth);
71-
std::cout << res->get() << std::endl;
69+
int f() {...}
70+
std::future<int> res = std::async(f);
71+
std::cout << res->get();
7272
\end{cppcode*}
7373
\end{exampleblock}
7474
\end{frame}
7575

7676
\begin{frame}[fragile]
7777
\frametitlecpp[11]{Mixing the two}
78-
\begin{block}{Is async running concurrent code ?}
78+
\begin{block}{Is async running concurrently ?}
7979
\begin{itemize}
8080
\item it depends!
8181
\item you can control this with a launch policy argument
8282
\begin{description}
83-
\item[std::launch::async] spawns a thread for immediate execution
83+
\item[std::launch::async] start executing immediately on a separate thread (may be a new thread, a thread pool, ...)
8484
\item[std::launch::deferred] causes lazy execution in current thread
8585
\end{description}
8686
\begin{itemize}
87-
\item execution starts when get() is called
87+
\item execution starts when \mintinline{cpp}{get()} is called on the returned future
8888
\end{itemize}
8989
\item default is not specified!
9090
\end{itemize}
9191
\end{block}
9292
\pause
9393
\begin{exampleblock}{Usage}
9494
\begin{cppcode*}{}
95-
int computeSth() {...}
96-
auto res = std::async(std::launch::async,
97-
computeSth);
98-
auto res2 = std::async(std::launch::deferred,
99-
computeSth);
95+
int f() {...}
96+
auto res1 = std::async(std::launch::async, f);
97+
auto res2 = std::async(std::launch::deferred, f);
10098
\end{cppcode*}
10199
\end{exampleblock}
102100
\end{frame}
103101

104102
\begin{frame}[fragile]
105103
\frametitlecpp[11]{Fine grained control on asynchronous execution}
106-
\begin{block}{std::packaged\_task template}
104+
\begin{block}{\texttt{std::packaged\_task} template}
107105
\begin{itemize}
108106
\item creates an asynchronous version of any function-like object
109107
\begin{itemize}
110108
\item identical arguments
111-
\item returns a std::future
109+
\item returns a \mintinline{cpp}{std::future}
112110
\end{itemize}
113111
\item provides access to the returned future
114112
\item associated with threads, gives full control on execution
@@ -117,10 +115,10 @@
117115
\pause
118116
\begin{exampleblock}{Usage}
119117
\begin{cppcode*}{}
120-
int task() { return 42; }
121-
std::packaged_task<int()> pckd_task(task);
122-
auto future = pckd_task.get_future();
123-
pckd_task();
118+
int f() { return 42; }
119+
std::packaged_task<int()> task(f);
120+
auto future = task.get_future();
121+
task();
124122
std::cout << future.get() << std::endl;
125123
\end{cppcode*}
126124
\end{exampleblock}

talk/expert/cpp20concepts.tex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
\end{frame}
1414

1515
\begin{frame}[fragile]
16-
\frametitlecpp[20]{The world before concepts}
16+
\frametitlecpp[17]{The world before concepts}
1717
\begin{block}{\cpp17 work around : SFINAE}
1818
\begin{itemize}
1919
\item Unsuited arguments can be avoided by inserting fake template arguments,
@@ -53,10 +53,10 @@
5353
\frametitlecpp[20]{Basic requirements}
5454
\begin{block}{A new keyword}
5555
\begin{itemize}
56-
\item The keyword {\it requires} let us define various constraints.
56+
\item The keyword \mintinline{cpp}{requires} let us define various constraints.
5757
\end{itemize}
5858
\end{block}
59-
\begin{exampleblock}{\cpp20 code}
59+
\begin{exampleblock}{With concepts}
6060
\scriptsize
6161
\begin{cppcode*}{}
6262
template<typename T>
@@ -134,7 +134,7 @@
134134
\begin{block}{Concepts as template parameters}
135135
\begin{itemize}
136136
\item concepts can be used in template parameter lists
137-
\item replacing {\it typename}
137+
\item replacing \mintinline{cpp}{typename}
138138
\end{itemize}
139139
\end{block}
140140
\begin{exampleblock}{}
@@ -148,7 +148,7 @@
148148
\end{exampleblock}
149149
\begin{block}{Concepts in abbreviated function arguments}
150150
\begin{itemize}
151-
\item concepts can be used together with {\it auto} in abbreviated function templates
151+
\item concepts can be used together with \mintinline{cpp}{auto} in abbreviated function templates
152152
\end{itemize}
153153
\end{block}
154154
\begin{exampleblock}{}
@@ -188,7 +188,7 @@
188188
\begin{block}{Concepts as boolean operators}
189189
\begin{itemize}
190190
\item Concepts can be used wherever a boolean is expected
191-
\item they can appear in {\it if constexpr} conditions
191+
\item they can appear in \mintinline{cpp}{if constexpr} conditions
192192
\begin{itemize}
193193
\item since they are evaluated at compile-time
194194
\end{itemize}
@@ -212,8 +212,8 @@
212212

213213
\begin{frame}[fragile]
214214
\frametitlecpp[20]{Advanced requirements overview}
215-
\begin{block}{{\it requires} as an expression}
216-
{\it requires} can express more than basic requirements. It can
215+
\begin{block}{\texttt{requires} as an expression}
216+
\mintinline{cpp}{requires} can express more than basic requirements. It can
217217
\begin{itemize}
218218
\item include other basic requirements
219219
\item list expressions that must be valid
@@ -239,9 +239,9 @@
239239
\frametitlecpp[20]{Requirements and concepts}
240240
\begin{block}{To be remembered}
241241
\begin{itemize}
242-
\item A template can now {\it requires} properties of its parameters
242+
\item A template can now \emph{require} properties of its parameters
243243
\item Compiler error messages clearly state which argument does not fulfill which requirement
244-
\item A set of requirements can be gathered in a {\it concept}
244+
\item A set of requirements can be gathered in a \emph{concept}
245245
\item Overload resolution takes requirements into account
246246
\item The standard library provides many ready-to-use concepts
247247
\item Writing a new good concept is an expert topic

0 commit comments

Comments
 (0)