Daisuke Maki
and 1 contributors

NAME

MooseX::KeyedMutex - Role To Add KeyedMutex

SYNOPSIS

  package MyClass;
  use Moose;

  with 'MooseX::KeyedMutex';

  no Moose;

  $object = MyClass->new( mutex => $mutex );
  $object = MyClass->new(
    mutex => {
      args => {
        sock => '....',
      }
    }
  );

  if (my $lock = $object->lock($name)) {
    ....
  }

DESCRIPTION

MooseX::KeyedMutex adds instant distributed locking to you objects via KeyedMutex.

METHODS

lock($key)

Attempts to acquire a lock by the name $key. On success, returns a KeyedMutex::Lock object. On failure, returns undef.

In case the object has *NOT* been initialized with a proper keyedmutex, lock() automatically goes into degraded mode and will immediately return success. In such cases, '0E0' will be returned.

mutex_required

If set to true, MooseX::KeyedMutex will croak whenever an attempt to lock is issued but no mutex is available

AUTHOR

Daisuke Maki <daisuke@endeworks.jp>

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html