04 Jul 2009 01:44:17 UTC
- Development release
- Distribution: KinoSearch
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (5)
- Testers (13 / 3 / 1)
- KwaliteeBus factor: 0
- License: perl_5
- Activity24 month
- Download (611.03KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionCREAMYG Marvin Humphreyand 1 contributors
- Marvin Humphrey <marvin at rectangular dot com>
- LICENSE, DISCLAIMER, BUGS, etc.
KinoSearch::Store::SharedLock - Shared (read) lock.
my $lock_factory = KinoSearch::Store::LockFactory->new( folder => $folder, agent_id => $hostname, ); my $shlock = $lock_factory->make_shared_lock( lock_name => 'snapshot_6r', timeout => 5000, );
SharedLock's interface is nearly identical to that of its parent class KinoSearch::Store::Lock, taking the same constructor arguments and implementing the same list of methods. It differs from Lock only in the semantics of two methods.
First, obtain() will not fail if another lock is held against the resource identified by
lock_name(though it might fail for other reasons).
Second, is_locked() returns true so long as some lock, somewhere is holding a lock on
lock_name. That lock could be this instance, or it could be another -- so is entirely possible to call release() successfully on a SharedLock object yet still have is_locked() return true.
As currently implemented, SharedLock differs from Lock in that each caller gets its own lockfile. Lockfiles still have filenames which begin with the lock name and end with ".lock", but each is also assigned a unique number which gets pasted between: "foo-44.lock" instead of "foo.lock". A SharedLock is considered fully released when no lock files with a given lock name are left.
my $shlock = KinoSearch::Store::SharedLock->new( lock_name => 'commit', # required timeout => 5000, # default: 0 folder => $folder, # required agent_id => $hostname, # required );
folder - The KinoSearch::Store::Folder where the lock file will reside.
lock_name - String identifying the resource to be locked.
agent_id - A per-machine identifier, usually the host name.
timeout - Time in milliseconds to keep retrying before abandoning the attempt to obtain() a lock.
Copyright 2005-2009 Marvin Humphrey
See KinoSearch version 0.30.