This code does the correct thing: each time I ran it, it adds a timestamp to the list. However, if I commented out the last line (simulating a failure before unlocking), the array does not grow, instead the last element was updated. From reading the documentation, it seems that since it is not unlocked, the other process can still obtain the tie, but can't change it. My question is why the lock is still there when the process ends? and if now I put back the last line, the program behaves back to normal again. What happened to the locks?use strict; use IPC::Shareable; my @test; my $shared = tie @test, 'IPC::Shareable', 'Test', {create=>1, mode=>06 +66}; $shared->shlock(); push @test, scalar(localtime); # just add something print join("\n", @test),"\n"; $shared->shunlock();
When one process is having the lock, is it possible for the other process to wait for the lock (like a typical synchronization), rather than getting a copy of the tied data? Thanks.
In reply to Shared memory with IPC::Shareable by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |