NAME

IPC::ConcurrencyLimit::Lock::Flock - flock() based locking

SYNOPSIS

use IPC::ConcurrencyLimit;

DESCRIPTION

This locking strategy implements flock() based concurrency control. Requires that your system has a sane flock() implementation as well as a non-blocking flock() mode.

Inherits from IPC::LimitConcurrency::Lock.

Take care not to attempt to use this on an NFS share or any other file system that does not implement atomic flock()!

METHODS

new

Given a hash ref with options, attempts to obtain a lock in the pool. On success, returns the lock object, otherwise undef.

Required options:

path

The directory that will hold the lock files. Created if it does not exist. It is suggested not to use a directory that may hold other data unless you also use the file_prefix option and ensure that your locks are unique.

file_prefix

An optional prefix which will be prepended to lock file names. If specified then files will be created that look like this:

$path/$file_prefix.1.lock
file_ext

By default lock files have a ".lock" suffix/extension. Set this option to specify a different extension.

max_procs

The maximum no. of locks (and thus usually processes) to allow at one time.

Other options:

lock_mode

Defaults to exclusive locks.

In particular circumstance, you might want to set this to shared. This subverts the way the normal concurrency limit works, but allows entirely different use cases.

lock_file

Returns the full path and name of the lock file.

path

Returns the directory in which the lock files resides.

AUTHOR

Steffen Mueller, smueller@cpan.org

Yves Orton

ACKNOWLEDGMENT

This module was originally developed for booking.com. With approval from booking.com, this module was generalized and put on CPAN, for which the authors would like to express their gratitude.

COPYRIGHT AND LICENSE

(C) 2011, 2012 Steffen Mueller. All rights reserved.

This code is available under the same license as Perl version
5.8.1 or higher.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.