does this mean, that in my example the $data value form %el has to be explicitly shared as well, or will it become shared automatically, since it's a scalar value and part of %el?
Whenever you use threads::shared::share() on a hash or array, any previous contents of that hash or array are silently discarded. It's a PITA but "working as designed". That is, it is operating the way the originators intended share() to work.
To achieve your aim, it is necessary to explicitely share every compound data structure (array or hash) prior to populating it.
One way of achieving this is to use an existing nested structure traversal utility (eg. Data::Rmap), and copy the data at each level into an appropriate shared structure before assigning a reference to the shared copy to the shared parent.
It is slow and gets messy to do this yourself. I've had a couple of goes at doing this in the past, but it is really something that should be done once, internally, rather than having to be recreated by each programmer.
In reply to Re: a question on sharing data structures across threads
by BrowserUk
in thread a question on sharing data structures across threads
by TOD
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |