Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Multi-thread friendly object life-time handling for XS modules

by Anonymous Monk
on Nov 06, 2017 at 10:30 UTC ( #1202807=note: print w/replies, xml ) Need Help??


in reply to Multi-thread friendly object life-time handling for XS modules

Um, store all libssh pointers/objects in a global array or hash, and only cleanup from perl swub destroy when nothing points to it, or in end block for global cleanup

or look to see how wxperl does it.

https://metacpan.org/pod/distribution/Wx/lib/Wx/Thread.pod

so make condition that main thread loads module. Then keep all real pointers alive in main...

sorry im afk and my memory is weak

wait, hiw does dbi do it? Oh righg it just croaks when user tries to share, sounds smart :)https://metacpan.org/pod/DBI#Threads-and-Thread-Safety

  • Comment on Re: Multi-thread friendly object life-time handling for XS modules

Replies are listed 'Best First'.
Re^2: Multi-thread friendly object life-time handling for XS modules
by salva (Abbot) on Nov 06, 2017 at 11:59 UTC
    Wx is a big and complex module, but after a brief inspection, it seems to me it is just using the non thread-safe sv_setref_pv function to create its wrapper objects.

    DBI uses the svt_dup approach.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1202807]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-11-18 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?