Skip to content

Commit 8a8facd

Browse files
committed
[NFC] Use {} for init and \n for endl in concurrency chapter.
1 parent aa2e80e commit 8a8facd

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

talk/concurrency/mutexes.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
for (int i=0; i < 100; i++) inc();
1111
};
1212
int main() {
13-
std::thread t1(inc100);
14-
std::thread t2(inc100);
13+
std::thread t1{inc100};
14+
std::thread t2{inc100};
1515
for (auto t: {&t1,&t2}) t->join();
16-
std::cout << a << std::endl;
16+
std::cout << a << "\n";
1717
}
1818
\end{cppcode*}
1919
\end{exampleblock}

talk/concurrency/threadsasync.tex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
void foo() {...}
1717
void bar() {...}
1818
int main() {
19-
std::thread t1(foo);
20-
std::thread t2(bar);
19+
std::thread t1{foo};
20+
std::thread t2{bar};
2121
for (auto t: {&t1,&t2}) t->join();
2222
}
2323
\end{cppcode*}
@@ -29,7 +29,7 @@
2929
\begin{exampleblock}{Can take a function and its arguments}
3030
\begin{cppcode*}{}
3131
void function(int j, double j) {...};
32-
std::thread t1(function, 1, 2.0);
32+
std::thread t1{function, 1, 2.0};
3333
\end{cppcode*}
3434
\end{exampleblock}
3535
\pause
@@ -40,10 +40,10 @@
4040
int operator() (int j) const { return i+j; };
4141
int m_i;
4242
};
43-
std::thread t2(AdderFunctor(2), 5);
43+
std::thread t2{AdderFunctor{2}, 5};
4444
int a;
45-
std::thread t3([](int i) { return i+2; }, a);
46-
std::thread t4([a] { return a+2; });
45+
std::thread t3{[](int i) { return i+2; }, a};
46+
std::thread t4{[a] { return a+2; }};
4747
\end{cppcode*}
4848
\end{exampleblock}
4949
\end{frame}
@@ -68,7 +68,7 @@
6868
\begin{cppcode*}{}
6969
int f() {...}
7070
std::future<int> res = std::async(f);
71-
std::cout << res->get();
71+
std::cout << res.get() << "\n";
7272
\end{cppcode*}
7373
\end{exampleblock}
7474
\end{frame}
@@ -116,7 +116,7 @@
116116
\begin{exampleblock}{Usage}
117117
\begin{cppcode*}{}
118118
int f() { return 42; }
119-
std::packaged_task<int()> task(f);
119+
std::packaged_task<int()> task{f};
120120
auto future = task.get_future();
121121
task();
122122
std::cout << future.get() << std::endl;

0 commit comments

Comments
 (0)