The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XAS::Lib::Lockmgr::Flom - Use the FLoM lock manager for locking.

SYNOPSIS

 use XAS::Lib::Lockmgr;

 my $key = '/var/lock/wpm/alerts';
 my $lockmgr = XAS::Lib::Lockmgr->new();

 $lockmgr->add(
     -key    => $key,
     -driver => 'Flom',
     -args => {
        port     => 9506,
        address  => '127.0.0.1',
        timeout  => 10,
        attempts => 10,
     }
 );

 if ($lockmgr->try_lock($key)) {

     $lockmgr->lock($key);

     ...

     $lockmgr->unlock($key);

 }

DESCRIPTION

This class uses the FLoM distributed lock manager to manage locks. This leverages the atomicity of using a centralized lock manager and allows for discretionary locking of resources.

CONFIGURATION

This module uses the following fields in -args.

attempts

The number of attempts to aquire the lock. The default is 30.

timeout

The number of seconds to wait between lock attempts. The default is 30.

host

The address of the host that is presenting the lock daemon. Defaults to 127.0.0.1.

port

The port that the lock daemon is listening on. Defaults to 28015.

METHODS

lock

Attempt to aquire a lock. Returns TRUE for success, FALSE otherwise.

unlock

Remove the lock. Returns TRUE for success, FALSE otherwise.

try_lock

Check to see if a lock could be aquired. Returns FALSE if not, TRUE otherwise.

exceptions

Returns the exceptions that you may not want to continue lock attemtps if triggered.

SEE ALSO

FLoM
XAS::Lib::Lockmgr
XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (c) 2012-2016 Kevin L. Esteb

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.