apparently we are digging deeper and deeper into the bouncing heart of perl itself with our discussion. i've just tested your workaround, and it worked quite fine - until:
foreach (keys %planets) {
lock %{$planets{$_}};
[...]
if ($planets{$_}->{'atime'} < $time - $some_limit) {
delete $planets{$_}; # remove the item from cache
}
}
obviously this cannot work, since we're having a lock on the variable in the very moment when we try to delete it, and consequently the result is:
panic: MUTEX_LOCK (22) ( shared.xs:90), and as i recall to have read somewhere that lock() isn't atomic, it would be no threadsafe solution if we put the delete() outside of the lock block. seems to me that locking the whole hash/ array is the only realistic possibility for the moment. but maybe some fine day in future one of the perl developers happens to stumble on this thread... ^^
--------------------------------
masses are the opiate for religion.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.