| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package IPC::Lock::RabbitMQ::HasTimeout; | 
| 2 | 1 |  |  | 1 |  | 11283 | use Moose::Role; | 
|  | 1 |  |  |  |  | 7076 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 3 | 1 |  |  | 1 |  | 9306 | use MooseX::Types::Moose qw/ Int /; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 14 |  | 
| 4 | 1 |  |  | 1 |  | 7676 | use AnyEvent; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 23 |  | 
| 5 | 1 |  |  | 1 |  | 5 | use Devel::GlobalDestruction; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 91 |  | 
| 6 | 1 |  |  | 1 |  | 97 | use namespace::autoclean; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 10 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | has timeout => ( | 
| 9 |  |  |  |  |  |  | is => 'ro', | 
| 10 |  |  |  |  |  |  | isa => Int, | 
| 11 |  |  |  |  |  |  | default => 30, | 
| 12 |  |  |  |  |  |  | ); | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | sub _gen_timer { | 
| 15 | 0 |  |  | 0 |  |  | my ($self, $cv, $name) = @_; | 
| 16 | 0 | 0 |  |  |  |  | return unless $self->timeout; | 
| 17 | 0 |  |  |  |  |  | AnyEvent->now_update; | 
| 18 |  |  |  |  |  |  | AnyEvent->timer( | 
| 19 |  |  |  |  |  |  | after => $self->timeout, | 
| 20 |  |  |  |  |  |  | cb => sub { | 
| 21 | 0 | 0 |  | 0 |  |  | return if in_global_destruction; | 
| 22 | 0 |  |  |  |  |  | $cv->croak("$name  timed out after " . $self->timeout); | 
| 23 |  |  |  |  |  |  | }, | 
| 24 | 0 |  |  |  |  |  | ); | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | 1; | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =head1 NAME | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | IPC::Lock::RabbitMQ::HasTimeout - Role for things which timeout. | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head2 timeout | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | The timeout value, in secions. | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =head1 METHODS | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =head2 _gen_timer | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | Genertes an AnyEvent->timer for the timeout. | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =cut | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  |  |