| 1 | package MangoX::Queue::Job; | ||||||||||
| 2 | |||||||||||
| 3 | 12 | ▶ | use Mojo::Base 'Mojo::EventEmitter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 0 | ▶ | has 'has_finished' => sub { 0 }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 6 | |||||||||||
| 7 | sub DESTROY { | ||||||||||
| 8 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||
| 9 | |||||||||||
| 10 | 0 | $self->finished; | |||||||||
| 11 | } | ||||||||||
| 12 | |||||||||||
| 13 | sub finished { | ||||||||||
| 14 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
finished: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | return if $self->has_finished; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | $self->has_finished(1); | |||||||||
| 18 | 0 | $self->emit_safe("finished"); | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 12 | 1; | |||||||||
| 22 | |||||||||||
| 23 | =encoding utf8 | ||||||||||
| 24 | |||||||||||
| 25 | =head1 NAME | ||||||||||
| 26 | |||||||||||
| 27 | MangoX::Queue::Job - A job consumed from L<MangoX::Queue> | ||||||||||
| 28 | |||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||
| 30 | |||||||||||
| 31 | L<MangoX::Queue::Job> is an object representing a job that has been consumed from L<MangoX::Queue>. | ||||||||||
| 32 | The object is just a document/job retrieved from the queue that is blessed, with an added desructor | ||||||||||
| 33 | method. | ||||||||||
| 34 | |||||||||||
| 35 | This class is used internally by L<MangoX::Queue> | ||||||||||
| 36 | |||||||||||
| 37 | =head1 SYNOPSIS | ||||||||||
| 38 | |||||||||||
| 39 | use MangoX::Queue::Job; | ||||||||||
| 40 | |||||||||||
| 41 | my $doc = {...}; | ||||||||||
| 42 | |||||||||||
| 43 | my $job = new MangoX::Queue::Job($doc); | ||||||||||
| 44 | |||||||||||
| 45 | =head1 ATTRIBUTES | ||||||||||
| 46 | |||||||||||
| 47 | L<MangoX::Queue::Job> implements the following attributes: | ||||||||||
| 48 | |||||||||||
| 49 | =head2 has_finished | ||||||||||
| 50 | |||||||||||
| 51 | my $finished = $job->has_finished; | ||||||||||
| 52 | $job->has_finished(1); | ||||||||||
| 53 | |||||||||||
| 54 | Is set to C<1> when the job has finished, either through the C<DESTROY> or C<finished> methods. | ||||||||||
| 55 | |||||||||||
| 56 | =head1 METHODS | ||||||||||
| 57 | |||||||||||
| 58 | L<MangoX::Queue::Job> implements the following methods: | ||||||||||
| 59 | |||||||||||
| 60 | =head2 DESTROY | ||||||||||
| 61 | |||||||||||
| 62 | Called automatically when C<$job> goes out of scope, undef'd, or refcount goes to 0. | ||||||||||
| 63 | |||||||||||
| 64 | Calls C<finished>, emitting a C<finished> event if it hasn't already been emitted. | ||||||||||
| 65 | |||||||||||
| 66 | =head2 finished | ||||||||||
| 67 | |||||||||||
| 68 | Emits a C<finished> event if it hasn't already been emitted. | ||||||||||
| 69 | |||||||||||
| 70 | =head1 SEE ALSO | ||||||||||
| 71 | |||||||||||
| 72 | L<MangoX::Queue::Tutorial>, L<Mojolicious>, L<Mango> | ||||||||||
| 73 | |||||||||||
| 74 | =cut | ||||||||||