Do you know where your variables are? | |
PerlMonks |
Re: How to share huge data structure between threads?by djantzen (Priest) |
on Jan 10, 2003 at 15:04 UTC ( [id://225809]=note: print w/replies, xml ) | Need Help?? |
Implicit sharing of nested structures is prohibited because it creates the potential for accidential sharing of private data. Since the ithreads model is predicated upon complete separation of all data by default, to allow the capacity to implicitly share references within shared parent structures is to open the door to accidental corruption of data. From perlthrtut
So the solution using threads is to take references to the things you wish to share at each level of a parent structure and to share them on a case by case basis. In other words, you must explicitly share not only the parent reference, but every reference contained therein. Here's some example code of a basic object with shared members:
It's a bother to do this, but it's better than accidental trampling of data. Hope this helps.
In Section
Seekers of Perl Wisdom
|
|