hi all,

i'm working on a daemon process, whose purpose lies in the cacheing of nested data structures and thus synchronizing the data between several processes. the daemon communicates with its clients via tcp/ip connections, it receives the data to be cached in serialized form (via Storable.pm). the process consists of mainly two threads (plus a logging one). the main thread listens on its socket, receives requests, performs all necessary actions, and sends the responses. the second thread periodically synchronizes the cached data with the respective files on disk. due to this construct all data have to be shared, e.g.:
our %planets : shared; our $response = SomeClass::TCP_IP_Response->new(@some_arguments); [...] lock %planets; if (exists $planets{$some_id}) { lock $planets{$some_id}; $response->content($planets{$some_id}->{'data'}); $planets{$some_id}->{'atime'} = time; } else { my $data; [...] # read the serialized data from disk my %el = ( 'data' => $data, 'atime' => time, 'deleted' => 0, 'modified' => 0 ); $planets{$some_id} = share(%el); }
what is confusing me here is that the manpage for threads::shared says: "C<share> will traverse up references exactly I<one> level. C<share(\$a)> is equivalent to C<share($a)>, while C<share(\\$a)> is not. This means that you must create nested shared data structures by first creating individual shared leaf notes, then adding them to a shared hash or array." 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?

maybe a silly question, but i'm really stuck at the moment. many thanks in advance.
--------------------------------
masses are the opiate for religion.

In reply to a question on sharing data structures across threads by TOD

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.