> I have written an XS interface into a library that performs I/O and then
> can asynchronously call a C function upon completion.  Is there a SAFE way
> I can reflect an asynchronous callback into Perl?

This might be impossible in your actual implementation, if so disregard my
idea.

If you have a threaded C lib (the I/O lib) you have a master thread. If you
have one perl interpreter started there you can simply make callbacks from
the threads to the main thread guarded by mutexes that in turn make
callbacks into perl. If the lib module is started by a perl interpreter you
still have one master thread. So the approach still works. The "added" cost
is by large a mutex and an extra function call. That isn't too much.

--
Aigars

Reply via email to