App::CPAN2Pkg::Lock - use Moose;


App-CPAN2Pkg documentation  | view source Contained in the App-CPAN2Pkg distribution.

Index


NAME

Top

App::CPAN2Pkg::Lock - use Moose;

VERSION

Top

version 2.111781

SYNOPSIS

Top

    use App::CPAN2Pkg::Lock;
    my $lock = App::CPAN2Pkg::Lock->new;
    $lock->get( 'foo' );
    # ...
    $lock->is_available; # false
    $lock->owner;        # foo
    $lock->get( 'bar' ); # dies
    # ...
    $lock->release;

DESCRIPTION

Top

This class implements a simple locking mechanism.

ATTRIBUTES

Top

owner

The lock owner (a string).

METHODS

Top

is_available

    $lock->is_available;

Return true if one can get control on $lock.

get

    $lock->get( $owner );

Try to give the $lock control to $owner. Dies if it's already owned by something else, or if new $owner is not specified.

release

    $lock->release;

Release $lock. It's now available for locking again.

AUTHOR

Top

Jerome Quelin <jquelin@gmail.com>

COPYRIGHT AND LICENSE

Top


App-CPAN2Pkg documentation  | view source Contained in the App-CPAN2Pkg distribution.