Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: XS/C, threads, and calling call_sv() with a code ref

by BrowserUk (Pope)
on Apr 26, 2018 at 03:35 UTC ( #1213569=note: print w/replies, xml ) Need Help??

in reply to XS/C, threads, and calling call_sv() with a code ref

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.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
  • Comment on Re: XS/C, threads, and calling call_sv() with a code ref

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2019-09-23 09:08 GMT
Find Nodes?
    Voting Booth?
    The room is dark, and your next move is ...

    Results (278 votes). Check out past polls.