in reply to Re^2: Avoid Locking Entire Hashes
in thread Avoid Locking Entire Hashes
That is a pretty nice solution, except of course it consumes ...
... an entire mirror data structure, completely unnecessarily.
Why not store the values in your existing hash using references to shared scalars, and lock the individual scalars directly rather than via a proxy?
sub safe_set { my $k = shift; my $v :shared = shift; lock $$h{ $k }; $h{$k} = \$v; }
The reasons why you can't lock individual hash elements are quite involved, but they boil down to the facts that:
A full explanation would probably require the original author to explain, but it probably comes down to the path of least resistance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Avoid Locking Entire Hashes
by jagan_1234 (Sexton) on Jun 14, 2011 at 22:59 UTC | |
by BrowserUk (Patriarch) on Jun 15, 2011 at 08:09 UTC | |
by BrowserUk (Patriarch) on Jun 15, 2011 at 04:22 UTC | |
by ikegami (Patriarch) on Jun 15, 2011 at 04:26 UTC | |
by BrowserUk (Patriarch) on Jun 15, 2011 at 04:29 UTC | |
by ikegami (Patriarch) on Jun 15, 2011 at 04:45 UTC | |
| |
by ikegami (Patriarch) on Jun 15, 2011 at 04:33 UTC | |
|
Re^4: Avoid Locking Entire Hashes
by jagan_1234 (Sexton) on Jun 15, 2011 at 17:45 UTC | |
by BrowserUk (Patriarch) on Jun 15, 2011 at 18:27 UTC | |
by jagan_1234 (Sexton) on Jun 15, 2011 at 20:35 UTC | |
by BrowserUk (Patriarch) on Jun 15, 2011 at 21:45 UTC | |
by jagan_1234 (Sexton) on Jun 15, 2011 at 22:04 UTC | |
| |
by ikegami (Patriarch) on Jun 15, 2011 at 18:29 UTC |