Why do you need to handle the destruction of these?Because i wanted to make Perl faster, smaller and even better. For example i wrote the Socket::Class module. It handles IPv6, includes SSL and it uses the C socket API instead of the PerlIO layer. Since MY_CXT clones with every thread, i'm using a global structure and a thread mutex to hold the data for Socket::Class. It works fine, is fast and saves memory. But in this case i need the correct time to destruct the shared data structure. I also started writing some new database drivers, which require similar mechanism.
The shared and global %MY_CXT hash was not a good example. But i used it to prevent from answering "take a look to MY_CXT mechanism". Because i did already many times :)
I believe i also did already understand what CLONE does. It's called once a new thread is created for each class or inherited class. Please see the following from perlmod/perldoc:If you want to CLONE all objects you will need to keep track of them per package.
Because of this i'm incrementing the reference counts every time CLONE is called.
Your example works as expected as long as the sub threads close before the main thread creates new ones.
Try it out. Set the sleep time in the sub threads to a higher value then the main thread sleep time. The reference counts become different. I think it starts at the point where the main variables are overwritten. ($obj1 = Class->new())
This is the problem that i have :)
In reply to Re^8: CLONE/DESTROY want work at all??
by spacepille
in thread CLONE/DESTROY want work at all??
by spacepille
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |