I've build a multithreaded perl, since I'm building an interface to a
threaded library, so I didn't have a choice.
Now I've run into this problem:
The library creates some threads, (not; use Threads; new Thread \&). And
in one of these I would like to call a list of callbacks.
How do I build a new perl-stack for this thread, so I can call the list of
callbacks.
The code for the callback is somthing like:
--------------------------8<-----------------------
typedef struct {
AV * cb;
} MY_CTX;
static void
my_cb(MY_CTX * context, int no)
{
int i;
SV ** svp;
for(i = 0 ; i <= av_len(context->cb) ; i++) {
if(svp = av_fetch(contest->cb)) {
...SOMETHING...
XPUSHs(sv_2mortal(newSViiv(no));
call_sv(*svp, G_DISCART);
...SOMETHING MORE...
}
}
}
...
SV *
get_cb_list(context)
MY_CTX * context
CODE:
{
RETVAL = newRV((SV *)context->cb);
}
OUTPUT:
RETVAL
--------------------------8<-----------------------
#!/usr/bin/perl
use MY;
$my = new MY;
$ar = $my->get_cb_list();
push @$ar, \&print_cb;
sub print_cb {
print(shift, "\n");
}
--------------------------8<-----------------------
And one more thing...
How do I subscribe to this list? [EMAIL PROTECTED] didnt seem to
do it. so please reply to me too.
--
Yours
Morten B�geskov (email: [EMAIL PROTECTED])
For every action, there is an equal and opposite criticism.