MooseX::KeyedMutex - Role To Add KeyedMutex
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)) { .... }
MooseX::KeyedMutex adds instant distributed locking to you objects via KeyedMutex.
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.
If set to true, MooseX::KeyedMutex will croak whenever an attempt to lock is issued but no mutex is available
Daisuke Maki <daisuke@endeworks.jp>
<daisuke@endeworks.jp>
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
To install MooseX::KeyedMutex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::KeyedMutex
CPAN shell
perl -MCPAN -e shell install MooseX::KeyedMutex
For more information on module installation, please visit the detailed CPAN module installation guide.