Coro
view release on metacpan or search on metacpan
# for short-lived callbacks, this reduces pressure on the coro pool
# as the chance is very high that the async_poll coro will be back
# in the idle state when cede returns
cede;
}
schedule; # sleep well
}
};
$unblock_scheduler->{desc} = "[unblock_sub scheduler]";
sub unblock_sub(&) {
my $cb = shift;
sub {
unshift @unblock_queue, [$cb, @_];
$unblock_scheduler->ready;
}
}
=item $cb = rouse_cb
Coro/Util.pm view on Meta::CPAN
our @EXPORT = qw(gethostbyname gethostbyaddr);
our @EXPORT_OK = qw(inet_aton fork_eval);
our $VERSION = 6.514;
our $MAXPARALLEL = 16; # max. number of parallel jobs
my $jobs = new Coro::Semaphore $MAXPARALLEL;
sub _do_asy(&;@) {
my $sub = shift;
$jobs->down;
my $fh;
my $pid = open $fh, "-|";
if (!defined $pid) {
die "fork: $!";
} elsif (!$pid) {
syswrite STDOUT, join "\0", map { unpack "H*", $_ } &$sub;
Coro/Util.pm view on Meta::CPAN
local $/;
# make my eyes hurt
pack "C*", unpack "(xxxC)*", <$fh>
}
}
my $alphachannel = do_it "/tmp/img.png";
=cut
sub fork_eval(&@) {
my ($cb, @args) = @_;
pipe my $fh1, my $fh2
or die "pipe: $!";
my $pid = fork;
if ($pid) {
undef $fh2;
( run in 0.362 second using v1.01-cache-2.11-cpan-49f99fa48dc )