Created
September 4, 2014 09:41
-
-
Save ishiduca/ab2b9b6e0cac627ca474 to your computer and use it in GitHub Desktop.
study coro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Coro; | |
my $n = 0; | |
async { | |
print "async 1 - $n\n"; | |
$n++; | |
cede; | |
print "async 2 - $n\n"; | |
$n++; | |
}; | |
print "main 1 - $n\n"; | |
$n++; | |
cede; | |
print "main 2 - $n\n"; | |
$n++; | |
cede; | |
print "main 3 - $n\n"; | |
# 出力 | |
# $nはメインプロセスとスレッドで共有している | |
# main 1 - 0 | |
# async 1 - 1 | |
# main 2 - 2 | |
# async 2 - 3 | |
# main 3 - 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment