17 Dec 2009 07:27:04 UTC
- Development release
- Distribution: KinoSearch
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (5)
- Testers (41 / 0 / 8)
- KwaliteeBus factor: 0
- License: perl_5
- Activity24 month
- Download (810.65KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionCREAMYG Marvin Humphreyand 1 contributors
- Marvin Humphrey <marvin at rectangular dot com>
- ABSTRACT METHODS
- COPYRIGHT AND LICENSE
KinoSearch::Store::Lock - Abstract class representing an interprocess mutex lock.
my $lock = $lock_factory->make_lock( name => 'write', timeout => 5000, ); $lock->obtain or die "can't get lock for " . $lock->get_name; do_stuff(); $lock->release;
Abstract class representing an interprocess mutex lock.
The Lock class produces an interprocess mutex lock. The default subclass uses dot-lock files, but alternative implementations are possible.
Each lock must have a name which is unique per resource to be locked. Each lock also has an "hostname" which should be unique per machine; it is used to help clear away stale locks.
my $lock = KinoSearch::Store::Lock->new( name => 'commit', # required folder => $folder, # required hostname => $hostname, # required timeout => 5000, # default: 0 interval => 1000, # default: 100 );
folder - A Folder.
name - File-system-friendly string identifying the resource to be locked.
hostname - A unique per-machine identifier.
timeout - Time in milliseconds to keep retrying before abandoning the attempt to obtain() a lock.
interval - Time in milliseconds between retries.
Call request() once per
intervaluntil request() returns success or the
timeouthas been reached.
Returns: true on success, false otherwise.
Make one attempt to acquire the lock.
The semantics of request() differ depending on whether shared() returns true. If the Lock is shared(), then request() should not fail if another lock is held against the resource identified by
name(though it might fail for other reasons). If it is not shared() -- i.e. it's an exclusive (write) lock -- then other locks should cause request() to fail.
Returns: true on success, false on failure.
Release the lock.
Indicate whether the resource identified by this lock's name is currently locked.
Returns: true if the resource is locked, false otherwise.
Release all locks that meet the following three conditions: the lock name matches, the hostname matches, and the process id that the lock was created under no longer identifies an active process.
KinoSearch::Store::Lock isa KinoSearch::Obj.
Copyright 2005-2009 Marvin Humphrey
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.