Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: XS callback to mpv_set_wakeup_callback

by dave_the_m (Monsignor)
on Jan 04, 2019 at 16:59 UTC ( #1228037=note: print w/replies, xml ) Need Help??

in reply to XS callback to mpv_set_wakeup_callback

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
PerlInterpreter* my_perl = pthread_getspecific(PL_thr_key);
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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1228037]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2019-05-21 09:41 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (132 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!