Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (40 sloc) 1.685 kb
07f4451 @bobtfish Docs etc
authored
1 NAME
2 IPC::Lock::RabbitMQ - Simple and reliable scoped locking for coarse
3 grained locks.
4
5 SYNOPSIS
6 my $locker1 = IPC::Lock::RabbitMQ->new( mq => $rabbitfoot );
7 my $locker2 = IPC::Lock::RabbitMQ->new( mq => $rabbitfoot );
b83d8a3 @bobtfish Update README
authored
8
07f4451 @bobtfish Docs etc
authored
9 {
10 my $lock = $locker1->lock("foo");
11 my $false = $locker2->lock("foo");
12 }
13 # $lock out of scope here, i.e.
14 # $lock = undef;
b83d8a3 @bobtfish Update README
authored
15
07f4451 @bobtfish Docs etc
authored
16 my $new_lock = $locker2->lock("foo");
17 $new_lock->unlock;
18
19 DESCRIPTION
20 This module uses RabbitMQ to provide locking for coarse grained locks.
21 The idea being that you want to take a lock to stop duplicate jobs doing
22 the same work you are doing.
23
24 The lock taken whilst your job is running can last quite a while, and
25 you don't want your lock to be broken by another process if you're still
26 working. Equally well, if you crash, you want the lock to be freed so
27 that another process can retry the job.
28
29 METHODS
30 new
31 Constructs a lock manager object. Supply it with the "mq" parameter
32 which contains either an instance of AnyEvent::RabbitMQ or
33 Net::RabbitFoot
34
35 lock ($key)
36 Take a lock named with a specified key. Returns false if the lock is
37 already held, returns a IPC::Lock::RabbitMQ::Lock object if the lock was
38 successful.
39
40 The lock is unlocked either by latting the IPC::Lock::RabbitMQ::Lock
41 object go out of scope, or by explicitly calling the unlock method on
42 it.
43
44 AUTHOR
45 Tomas Doran (t0m) "<bobtfish@bobtfish.net>".
46
47 COPYRIGHT & LICENSE
48 Copyright 2011 the above author(s).
49
50 This sofware is free software, and is licensed under the same terms as
51 perl itself.
52
Something went wrong with that request. Please try again.