There's more than one way to do things | |
PerlMonks |
Re: XS callback to mpv_set_wakeup_callbackby dave_the_m (Monsignor) |
on Jan 04, 2019 at 16:59 UTC ( [id://1228037]=note: print w/replies, xml ) | Need Help?? |
I suspect your problem lies in some random foreign thread calling the callback. The dTHX macro in your callback function expands (depending on platform and configuration) to something like
This means that it attempts to set the current interpreter (my_perl) to whatever value is stored in thread-local storage for that thread. For a perl thread, that value will point to the interpreter associated with that thread. For a foreign thread, it's likely to be NULL. The question is, if a foreign thread calls the callback, what interpreter structure should it use? Once you have decided that, then you'll need to do at some point. See perlguts and perlembed. The question of what interpreter to use depends on your setup - how threads are created and managed - but in any case, you need to avoid two separate threads sharing the same interpreter. Dave.
In Section
Seekers of Perl Wisdom
|
|