Since CLONE deals with the package and DESTROY deals with the object, it's not possible to get a module threadsafe, when it uses shared stuff?
| [reply] |
What makes you think it is not threadsafe?
It is doing what you are asking for. You have a global structure. As each thread spawns, it walks the whole global structure, while locking appropriately. If you don't want it to walk the whole global structure don't.
If that is not what you meant to ask for, then don't ask for that.
In general with threads I strongly recommend having the simplest possible design. And then thinking through consequences very, very carefully. Because things will interact in unexpected ways. And when you've got multiple threads (or processes) around whose interactions with you are all mixed up, you can easily get very, very confused.
| [reply] |
My intention to ask was.. How can i use shared things like file handles in XS modules, when CLONE/DESTROY don't provide a clean way for destruction in the case that i showed in the example above? I wrote some XS modules to make Perl faster and smaller. I'm using this modules in serveral programs, but it doesn't work right. MY_CXT makes no sense when i have a file handle or socket handle in it, which must be closed. It seems that Perl doesn't work right with threads. I decided to go away from it. Bummer!
| [reply] |