The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

IPC::Lock - Perl extension for locking across boxes

SYNOPSIS

  IPC::Lock is a base module and depends on other objects to implement it.

  Current modules include IPC::Lock::Memcached.  
  
  Please refer to a child module for their respective usage.

  Generally, you instantiate an $object via new.  The new will contain
  connection parameters.
  
  Then call

  $object->lock($key)

  where $key is a unique identifier.  The default value set for the lock comes
  from $self->atomic_value, which by default is

  return "$self->{hostname}:$$:" . scalar gettimeofday;
  
  The value can potentially be used for debugging.
  
  When $object leaves scope,

  $object->unlock

  gets called.  When called via destroy, unlock will destroy the last 
  $key that was locked.

PARAMETERS

  The following parameters can be set in the instantiation:

  ttl       - number of seconds the lock should last, default is 60
  patience  - number of seconds to wait for a lock, default is 2
  increment - number of seconds to wait between atomic attempts, default is 0.05

  So, to instantiate with a ttl of a day, patience of a minute and increment of a second

  my $object = IPC::Lock::Child->new({
      ttl       => 86400,
      patience  => 60,
      increment => 1,
  });

DESCRIPTION

  Simple way to lock across multiple boxes.  Child modules need to implement two methods

  atomic - a way to lock atomically
  unatomic - a way to undo your atomic function

THANKS

Thanks to Perrin Harkins for suggesting the IPC::Lock namespace. Thanks to File::NFSLock for graceful_sig.

AUTHOR

Earl Cahill, <cpan@spack.net>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Earl Cahill

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.