From f3984f64129e15b2e505b9e73f6550dd18af2a3a Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 23 Mar 2017 13:25:18 +0100 Subject: [PATCH] no need for separate vars --- examples/concurrency.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/concurrency.cc b/examples/concurrency.cc index 67e7a0d..1f4721a 100644 --- a/examples/concurrency.cc +++ b/examples/concurrency.cc @@ -27,8 +27,7 @@ int main() { * implementing a 1:1 (kernel-level) scheduling - very expensive on * Windows, less expensive on Unix-likes (but more than coroutines) */ - thread_scheduler tsched; - tsched.start([&foo]() { + thread_scheduler{}.start([&foo]() { writeln("(1) 1:1 scheduler: starting..."); foo(); writeln("(1) 1:1 scheduler: finishing..."); @@ -39,8 +38,7 @@ int main() { * per task, implementing N:1 (user-level) scheduling - very cheap * and portable everywhere but obviously limited to only one thread */ - simple_coroutine_scheduler scsched; - scsched.start([&foo]() { + simple_coroutine_scheduler{}.start([&foo]() { writeln("(2) N:1 scheduler: starting..."); foo(); writeln("(2) N:1 scheduler: finishing..."); @@ -52,8 +50,7 @@ int main() { * a hybrid M:N approach - this benefits from multicore systems and * also is relatively cheap (you can create a big number of tasks) */ - coroutine_scheduler csched; - csched.start([&foo]() { + coroutine_scheduler{}.start([&foo]() { writeln("(3) M:N scheduler: starting..."); foo(); writeln("(3) M:N scheduler: finishing...");