Re: XS callback function

[email protected] ("muppet")
Newsgroups perl.xs
Message-ID <[email protected]>
Private and Confidential wrote:
> Confirmed, the library I am wrapping runs in a separate thread and runs
> its callbacks from there. "context" is a good keyword and led me to dTHX
> and PERL_SET_CONTEXT. I haven't found a good example of using these yet.
> Adding dTHX did get me past dSP, but I die consistently in ENTER now.

Everything i know on the subject is encoded in gperl_marshal.h and
GPerlClosure.xs in the Glib extension.  I recall having to do "interesting"
work to get the interpreter context set up appropriately to allow callbacks on
other threads, but it was almost seven years ago and i couldn't begin to
explain it now.

http://git.gnome.org/browse/perl-Glib/tree/gperl_marshal.h
http://git.gnome.org/browse/perl-Glib/tree/GClosure.xs

Specifically, look at GPerlCallback, which is what gtk2-perl uses to wrap the
bare functions used as callbacks throughout the gnome api.

Things to look for:  gperl_callback_invoke(), GPERL_CALLBACK_MARSHAL_INIT().


-- 
muppet <scott at asofyet dot org>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.