no need for separate vars

master
Daniel Kolesa 2017-03-23 13:25:18 +01:00
parent 972c27e181
commit f3984f6412
1 changed files with 3 additions and 6 deletions

View File

@ -27,8 +27,7 @@ int main() {
* implementing a 1:1 (kernel-level) scheduling - very expensive on * implementing a 1:1 (kernel-level) scheduling - very expensive on
* Windows, less expensive on Unix-likes (but more than coroutines) * Windows, less expensive on Unix-likes (but more than coroutines)
*/ */
thread_scheduler tsched; thread_scheduler{}.start([&foo]() {
tsched.start([&foo]() {
writeln("(1) 1:1 scheduler: starting..."); writeln("(1) 1:1 scheduler: starting...");
foo(); foo();
writeln("(1) 1:1 scheduler: finishing..."); writeln("(1) 1:1 scheduler: finishing...");
@ -39,8 +38,7 @@ int main() {
* per task, implementing N:1 (user-level) scheduling - very cheap * per task, implementing N:1 (user-level) scheduling - very cheap
* and portable everywhere but obviously limited to only one thread * and portable everywhere but obviously limited to only one thread
*/ */
simple_coroutine_scheduler scsched; simple_coroutine_scheduler{}.start([&foo]() {
scsched.start([&foo]() {
writeln("(2) N:1 scheduler: starting..."); writeln("(2) N:1 scheduler: starting...");
foo(); foo();
writeln("(2) N:1 scheduler: finishing..."); writeln("(2) N:1 scheduler: finishing...");
@ -52,8 +50,7 @@ int main() {
* a hybrid M:N approach - this benefits from multicore systems and * a hybrid M:N approach - this benefits from multicore systems and
* also is relatively cheap (you can create a big number of tasks) * also is relatively cheap (you can create a big number of tasks)
*/ */
coroutine_scheduler csched; coroutine_scheduler{}.start([&foo]() {
csched.start([&foo]() {
writeln("(3) M:N scheduler: starting..."); writeln("(3) M:N scheduler: starting...");
foo(); foo();
writeln("(3) M:N scheduler: finishing..."); writeln("(3) M:N scheduler: finishing...");