IPC::Lock - simple and safe local/network locking


IPC-Lock documentation  | view source Contained in the IPC-Lock distribution.

Index


NAME

Top

IPC::Lock - simple and safe local/network locking

SYNOPSIS

Top

  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 a $lock object via new.  The new will contain
  connection parameters.

  Then call

  $lock->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 $lock leaves scope,

  $lock->unlock

  gets called.  When called via destroy, unlock will destroy the last 
  $key that was locked.  To avoid relying on this magic, call 
  $lock->unlock explicitly.

PARAMETERS

Top

  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 $lock = IPC::Lock::Child->new({
      ttl       => 86400,
      patience  => 60,
      increment => 1,
  });

DESCRIPTION

Top

  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

Top

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

AUTHOR

Top

Earl Cahill, <cpan@spack.net>

COPYRIGHT AND LICENSE

Top


IPC-Lock documentation  | view source Contained in the IPC-Lock distribution.