You might find a solution here. Its a long subthread, and the good stuff is towards the end, but (and you'll get this later) you'll need the earlier context.
The best (most complete) version of the test code is here.
The basic idea behind the mechanism is that you call a setup() function from each thread you wish to call back to, passing the callback address, and implicitly, the interpreter context. That setup() function records both, and when the callback occurs, it (temporarily) switches to the appropriate context before calling the callback, and then switches back after.
I haven't touched that code, or any derivatives of it in at least 5 years, nor much perl threading in at least 2. The last version of perl I installed was 5.20! So I am unaware of any changes since (and actually before as I never made it past 5.16 for anything real).
What I'm saying, is if you try the code, I may not be much help in support of it :(
But it might solve your problem if no other solution is presented.
Another (off-the-cuff) possibility would be to spawn a new perl thread to handle the callback and then have it loop over a short sleep. Something like that, but I haven't though it through.
In reply to Re: XS/C, threads, and calling call_sv() with a code ref
by BrowserUk
in thread XS/C, threads, and calling call_sv() with a code ref
by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |