SDF::Lock::Selective

SDF::Lock::Selective can lock/unlock a file or filehandle using 'selective' locking.
Download

SDF::Lock::Selective Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Chris Cobb
  • Publisher web site:
  • http://search.cpan.org/~ccobb/PTools-0.02/lib/PTools/Date/Format.pm

SDF::Lock::Selective Tags


SDF::Lock::Selective Description

SDF::Lock::Selective can lock/unlock a file or filehandle using 'selective' locking. SDF::Lock::Selective can lock/unlock a file or filehandle using 'selective' locking.SYNOPSISObtain lock on a filename or filepath use PTools::SDF::Lock::Selective; $lockObj = new PTools::SDF::Lock::Selective; ($stat,$err) = $lockObj->lock( $fileName ); or $lockObj->lock( $fileName, $maxRetries, $sleepTime, $lockMode, $openMode ); ($stat,$err) = $lockObj->status; ($stat,$err) = $lockObj->unlock;The '$fileName' need not exist prior to calling the 'lock' method, but it will exist if the lock succeeds.Default for the '$openMode' variable is 0644, or '-rw-r--r--')Explicit unlock is unnecessary. Simply allow the '$lockObj' variable to fall out of scope (or exit the script, undefine, etc.) to release the lock.Obtain lock on an open filehandle use Fcntl; use PTools::SDF::Lock::Selective; $lockObj = new PTools::SDF::Lock::Selective; local(*FH); sysopen(FH, "/some/file", O_RDWR|O_CREAT, 0644) || die $!; $fh = *FH; ($stat,$err) = $lockObj->lock( $fh ); or ($stat,$err) = $lockObj->lock( $fh, $maxRetries, $sleepTime, $lockMode );The 'status' and 'unlock' methods are the same as above, and an '$openMode' parameter is obviously not needed here.Obtain lock on an instance of an 'SDF::< module >' class use PTools::SDF::INI; # or PTools::SDF::SDF, or PTools::SDF::TAG $iniObj = new PTools::SDF::INI( $fileName ); $iniObj->extend( , "PTools::SDF::Lock::Selective"); ($stat,$err) = $iniObj->lock( $maxRetries, $sleepTime, $lockMode );The 'status' and 'unlock' methods are the same as above.Note that the braces () used in the above example show the litersl syntax used to pass an array reference into a subroutine. They are not used here to imply optional parameters. Optionally, use: $arrayRef = ; $iniObj->extend( $arrayRef, "PTools::SDF::Lock::Selective");Invoke lock method from within an 'SDF::< module >' classThe lock and unlock methods are implemented as extendible methods in an abstract base class. See PTools::SDF::File or EPTools::xtender for discussion and examples of this mechanism. Requirements: · Perl


SDF::Lock::Selective Related Software