Async-Interrupt
view release on metacpan or search on metacpan
Interrupt.pm view on Meta::CPAN
which returns the Perl-side callback, and C<_attach>, which configures
the signalling functioon that is safe toc all from another thread. For
simplicity, we will use global variables to store the functions, normally
you would somehow attach them to C<$self>.
The C<c_func> simply returns the address of a static function and arranges
for the object pointed to by C<$self> to be passed to it, as an integer:
void
_c_func (SV *loop)
PPCODE:
EXTEND (SP, 2);
PUSHs (sv_2mortal (newSViv (PTR2IV (c_func))));
PUSHs (sv_2mortal (newSViv (SvRV (loop))));
This would be the callback (since it runs in a normal Perl context, it is
permissible to manipulate Perl values):
static void
c_func (pTHX_ void *loop_, int value)
{
Interrupt.xs view on Meta::CPAN
PL_sighandlerp = async_sighandler;
sig_pending = &PL_sig_pending;
psig_pend = PL_psig_pend;
asyncs = newAV ();
CvNODEBUG_on (get_cv ("Async::Interrupt::scope_block", 0)); /* otherwise calling scope can be the debugger */
PROTOTYPES: DISABLE
void
_alloc (SV *cb, void *c_cb, void *c_arg, SV *fh_r, SV *fh_w, SV *signl, SV *pvalue)
PPCODE:
{
SV *cv = SvOK (cb) ? SvREFCNT_inc (s_get_cv_croak (cb)) : 0;
async_t *async;
Newz (0, async, 1, async_t);
XPUSHs (sv_2mortal (newSViv (PTR2IV (async))));
/* TODO: need to bless right now to ensure deallocation */
av_push (asyncs, TOPs);
Interrupt.xs view on Meta::CPAN
}
}
void
signal_hysteresis (async_t *async, int enable)
CODE:
async->hysteresis = enable;
void
signal_func (async_t *async)
PPCODE:
EXTEND (SP, 2);
PUSHs (sv_2mortal (newSViv (PTR2IV (async_signal))));
PUSHs (sv_2mortal (newSViv (PTR2IV (async))));
void
scope_block_func (SV *self)
PPCODE:
EXTEND (SP, 2);
PUSHs (sv_2mortal (newSViv (PTR2IV (scope_block))));
PUSHs (sv_2mortal (newSViv (PTR2IV (SvRV (self)))));
IV
c_var (async_t *async)
CODE:
RETVAL = PTR2IV (async->valuep);
OUTPUT:
RETVAL
Interrupt.xs view on Meta::CPAN
else
RETVAL = newSViv (signum);
}
OUTPUT:
RETVAL
MODULE = Async::Interrupt PACKAGE = Async::Interrupt::EventPipe PREFIX = s_epipe_
void
new (const char *klass)
PPCODE:
{
s_epipe *epp;
Newz (0, epp, 1, s_epipe);
XPUSHs (sv_setref_iv (sv_newmortal (), klass, PTR2IV (epp)));
if (s_epipe_new (epp) < 0)
croak ("Async::Interrupt::EventPipe: unable to create new event pipe");
}
void
filenos (s_epipe *epp)
PPCODE:
EXTEND (SP, 2);
PUSHs (sv_2mortal (newSViv (epp->fd [0])));
PUSHs (sv_2mortal (newSViv (epp->fd [1])));
int
fileno (s_epipe *epp)
ALIAS:
fileno = 0
fileno_r = 0
fileno_w = 1
Interrupt.xs view on Meta::CPAN
void
s_epipe_signal (s_epipe *epp)
void
s_epipe_drain (s_epipe *epp)
void
signal_func (s_epipe *epp)
ALIAS:
drain_func = 1
PPCODE:
EXTEND (SP, 2);
PUSHs (sv_2mortal (newSViv (PTR2IV (ix ? s_epipe_drain : s_epipe_signal))));
PUSHs (sv_2mortal (newSViv (PTR2IV (epp))));
void
s_epipe_wait (s_epipe *epp)
void
s_epipe_renew (s_epipe *epp)
the signalling functioon that is safe toc all from another thread. For
simplicity, we will use global variables to store the functions,
normally you would somehow attach them to $self.
The "c_func" simply returns the address of a static function and
arranges for the object pointed to by $self to be passed to it, as an
integer:
void
_c_func (SV *loop)
PPCODE:
EXTEND (SP, 2);
PUSHs (sv_2mortal (newSViv (PTR2IV (c_func))));
PUSHs (sv_2mortal (newSViv (SvRV (loop))));
This would be the callback (since it runs in a normal Perl context, it
is permissible to manipulate Perl values):
static void
c_func (pTHX_ void *loop_, int value)
{
( run in 0.868 second using v1.01-cache-2.11-cpan-71847e10f99 )