AnyEvent-XSPromises
view release on metacpan or search on metacpan
XSPromises.xs view on Meta::CPAN
ENTER;
SAVETMPS;
PUSHMARK(SP);
EXTEND(SP, input_count);
for (i = 0; i < input_count; i++) {
PUSHs(input[i]);
}
PUTBACK;
/* Clear $_ so that callbacks don't end up talking to each other by accident */
SAVE_DEFSV;
DEFSV_set(sv_newmortal());
count = call_sv(perl_fn, G_EVAL|G_ARRAY);
SPAGAIN;
error = ERRSV;
if (SvTRUE(error)) {
result = xspr_result_new(aTHX_ XSPR_RESULT_REJECTED, 1);
result->result[0] = newSVsv(error);
lib/AnyEvent/XSPromises/Loader.pm view on Meta::CPAN
BEGIN { $AE_PID= -1; }
sub ___notify_callback {
if ($$ != $AE_PID) {
___reset_pipe();
} else {
sysread $PIPE_IN, my $read_buf, 16;
}
# sort makes perl push a pseudo-block on the stack that prevents callback code from using
# next/last/redo. Without it, an accidental invocation of one of those could cause serious
# problems. We have to assign it to @useless_variable or Perl thinks our code is a no-op
# and optimizes it away.
my @useless_variable= sort { AnyEvent::XSPromises::___flush(); 0 } 1, 2;
}
sub ___reset_pipe {
close $PIPE_IN if $PIPE_IN;
close $PIPE_OUT if $PIPE_OUT;
pipe($PIPE_IN, $PIPE_OUT);
$AE_WATCH= AE::io($PIPE_IN, 0, \&___notify_callback);
( run in 1.315 second using v1.01-cache-2.11-cpan-de7293f3b23 )