NAME
XAS::Lib::Modules::Locking - A module to provide discretionary directory locking.
SYNOPSIS
package My::App;
use XAS::Class
version => '0.01',
base => 'XAS::Lib::App',
;
sub main {
if ($self->lockmgr->lock_directories('here', 'there')) {
$self->lockmgr->unlock_directories('here', 'there);
}
}
1;
DESCRIPTION
This module provides discretionary directory locking. This is used to coordinate access to shared resources. It is implemented as a singleton. This module will also auto-load if "lockmgr" is used as a method invocation.
METHODS
new($parameters)
This method initializes the module. It takes these parameters:
- -lockfile
-
The optional name of the lock file. It defaults to "locked".
- -max
-
The optional number of retries. This defaults to 20.
- -delay
-
The number of seconds to delay before retrying to acquire the lock. This defaults to 1 second.
- -hold
-
The amount of time to hold a lock. After this time the lock is considered "stale". This defaults to 900 seconds.
lock_directory($directory)
This method will lock a single directory. It takes these parameters:
unlock_directory($directory)
This method will unlock a single directory. It takes these parameters:
lock_directories($source, $destination)
This method will attempt to lock the source and destination directories. It takes these parameters:
unlock_directories($source, $destination)
This method will unlock the source and destination directories. It takes these parameters:
lock_file_name($directory)
This method returns the locks file name. It can be overridden if needed. The default name is 'locked'. It takes the following parameters:
SEE ALSO
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (C) 2014 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.