NAME
Gestinanna::POF::Lock - Base class for locking mechanisms
SYNOPSIS
package My::ObjectClass;
use base qw(
Gestinanna::POF::Secure::Type
Gestinanna::POF::Lock::Type
Gestinanna::POF::Type
);
DESCRIPTION
** The lock protocol is still in development and may change in the next few releases. **
Deriving a locking implementation from this base class and including it in the inheritance of a data object provides a generic way to add (advisory) locking semantics to any data object.
METHODS
The following methods are expected in any implementation.
$object -> lock
This method should try to obtain a lock on the object. If unable to, it should return undef. Otherwise, it should return a true value such as the number of unlock
s needed to completely release the object. An object may be locked multiple times by the same process, requiring the same number of unlock
s. This makes some algorithms more efficient and allows them not to make assumptions regarding the locked state of any objects they may need.
$object -> unlock
This method should release the lock on the object. Calls to unlock
and lock
should be balanced, though it is safer to have more unlock
s than lock
s.
$object is_locked
This method should return the identifier of the object that ownes the lock if there is a lock. Otherwise, it should return undef
.
AUTHOR
James Smith, <jsmith@cpan.org>
COPYRIGHT
Copyright (C) 2003 Texas A&M University. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.