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 (though it might fail for other reasons).
Second, is_locked() returns true so long as some lock, somewhere is holding
a lock on the resource identified by 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
);
KinoSearch::Store::SharedLock isa KinoSearch::Store::Lock isa KinoSearch::Obj.
Copyright 2005-2008 Marvin Humphrey
See KinoSearch version 0.20.