When the main Coro ends, the program exits and the other Coros are abandonned. Wait for the other Coro at the end of the program if you want it to run to completion.
For example, in this code the first loop will take more time than the second, but after the second one we wait for the first one to complete so the program doesn't exit. If you remove the join call, the program will exit early.
use IO::Handle; use Coro; use Coro::Timer; my $s = async { for (0..11) { Coro::Timer::sleep 0.2; printflush STDOU +T "s"; } }; for (0..9) { Coro::Timer::sleep 0.1; printflush STDOUT "m"; } $s->join;
Also, don't listen to Anon above, for Coro these days doesn't have so much bugs and memory leaks, provided you use a recent version of both Coro and the perl core itself.
In reply to Re: Use Coro for multi-threads, is this right?
by ambrus
in thread Use Coro for multi-threads, is this right?
by ilxl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |