Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    SDF::Lock::Selective 0.01

    Download button

    No screenshots available
    Downloads: 377  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Chris Cobb | More programs
    Perl Artistic License / FREE
    August 29th, 2007, 11:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    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.

    SYNOPSIS

    Obtain 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( [ "lock","unlock" ], "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 = [ "lock", "unlock" ];

    $iniObj->extend( $arrayRef, "PTools::SDF::Lock::Selective");

    Invoke lock method from within an 'SDF::< module >' class
    The 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.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    selective lock | unlock filehandle | Perl module | SDF | selective | lock

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM