On 22/08/12 06:45 AM, Nigel Horne via RT wrote:
Show quoted text> Wed Aug 22 06:45:04 2012: Request 79133 was acted upon.
> Transaction: Ticket created by NHORNE
> Queue: IPC-Semaphore-Concurrency
> Subject: add have_lock()
> Broken in: 0.02
> Severity: Wishlist
> Owner: Nobody
> Requestors: NHORNE@cpan.org
> Status: new
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=79133 >
>
>
> It would be good to have a have_lock() call for software assertions.
> That way code could verify asserts that the caller must have locked the
> resource.
>
> e.g.
>
> my write_some_bit_of_data {
> my $self = shift;
>
> die "failed sanity check" unless($self->have_lock());
> # blah blah
> }
>
Hi Nigel,
Thanks for the suggestion.
Unfortunately it's not something that is available natively with
semaphores, and since they are merely shared counters it would be hard
to make it meaningful when someone use it in weird ways like increasing
and decreasing the semaphore multiple times, and there would be no way
to track "unlocks" in forked processes...
The have_lock could then become more dangerous than anything by making
users thing they're safe when they aren't.
Regards,
--
Thomas