Kazuhiro Osawa > ExclusiveLock-Guard-0.07 > ExclusiveLock::Guard

Download:
ExclusiveLock-Guard-0.07.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.07   Source  

NAME ^

ExclusiveLock::Guard - lexically-scoped lock management

SYNOPSIS ^

    use ExclusiveLock::Guard;

    sub blocking_transaction {
        my $lock = ExclusiveLock::Guard->new('/tmp/foo.lock')
            or die 'lock error: ' . ExclusiveLock::Guard->errstr;
        # inner of lock
    }
    blocking_transaction();
    # outer of lock

for non-blocking

    sub nonblocking_transaction {
        my $lock = ExclusiveLock::Guard->new('/tmp/foo.lock', nonblocking => 1 )
            or die 'lock error: ' . ExclusiveLock::Guard->errstr;
        unless ($lock->is_locked) {
            warn 'is locked';
            return;
        }

        # inner of lock
    }
    nonblocking_transaction();
    # outer of lock

DESCRIPTION ^

ExclusiveLock::Guard is very simple lock maneger. To automatically create and remove the lock file.

AUTHOR ^

Kazuhiro Osawa <yappo {at} shibuya {dot} pl>

COPYRIGHT ^

Copyright 2012- Kazuhiro Osawa

LICENSE ^

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: