| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Gearman::Job; |
|
2
|
12
|
|
|
12
|
|
2859
|
use version (); |
|
|
12
|
|
|
|
|
1577
|
|
|
|
12
|
|
|
|
|
537
|
|
|
3
|
|
|
|
|
|
|
$Gearman::Job::VERSION = version->declare("2.002.001"); #TRIAL |
|
4
|
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
61
|
use strict; |
|
|
12
|
|
|
|
|
16
|
|
|
|
12
|
|
|
|
|
275
|
|
|
6
|
12
|
|
|
12
|
|
44
|
use warnings; |
|
|
12
|
|
|
|
|
17
|
|
|
|
12
|
|
|
|
|
335
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
12
|
|
|
12
|
|
433
|
use Gearman::Util (); |
|
|
12
|
|
|
|
|
27
|
|
|
|
12
|
|
|
|
|
207
|
|
|
9
|
12
|
|
|
12
|
|
47
|
use Carp (); |
|
|
12
|
|
|
|
|
27
|
|
|
|
12
|
|
|
|
|
355
|
|
|
10
|
12
|
|
|
|
|
806
|
use Ref::Util qw/ |
|
11
|
|
|
|
|
|
|
is_plain_scalarref |
|
12
|
|
|
|
|
|
|
is_ref |
|
13
|
12
|
|
|
12
|
|
722
|
/; |
|
|
12
|
|
|
|
|
666
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Gearman::Job - Job in gearman distributed job system |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
I is the object that's handed to the worker subrefs |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use fields ( |
|
29
|
12
|
|
|
|
|
84
|
'func', |
|
30
|
|
|
|
|
|
|
'argref', |
|
31
|
|
|
|
|
|
|
'handle', |
|
32
|
|
|
|
|
|
|
'jss', # job server's socket |
|
33
|
12
|
|
|
12
|
|
562
|
); |
|
|
12
|
|
|
|
|
1346
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
1
|
|
|
1
|
0
|
1281
|
my ($self, $func, $argref, $handle, $jss) = @_; |
|
37
|
1
|
50
|
|
|
|
12
|
unless (is_ref($self)) { |
|
38
|
1
|
|
|
|
|
3
|
$self = fields::new($self); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
3056
|
$self->{func} = $func; |
|
42
|
1
|
|
|
|
|
2
|
$self->{handle} = $handle; |
|
43
|
1
|
|
|
|
|
2
|
$self->{argref} = $argref; |
|
44
|
1
|
|
|
|
|
2
|
$self->{jss} = $jss; |
|
45
|
1
|
|
|
|
|
2
|
return $self; |
|
46
|
|
|
|
|
|
|
} ## end sub new |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 set_status($numerator, $denominator) |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Updates the status of the job (most likely, a long-running job) and sends |
|
51
|
|
|
|
|
|
|
it back to the job server. I<$numerator> and I<$denominator> should |
|
52
|
|
|
|
|
|
|
represent the percentage completion of the job. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub set_status { |
|
57
|
1
|
|
|
1
|
1
|
439
|
my $self = shift; |
|
58
|
1
|
|
|
|
|
2
|
my ($nu, $de) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $req = Gearman::Util::pack_req_command("work_status", |
|
61
|
1
|
|
|
|
|
5
|
join("\0", $self->{handle}, $nu, $de)); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Carp::croak "work_status write failed" |
|
64
|
1
|
0
|
|
|
|
4
|
unless Gearman::Util::send_req($self->{jss}, \$req); |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
return 1; |
|
67
|
|
|
|
|
|
|
} ## end sub set_status |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 argref() |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub argref { |
|
74
|
1
|
|
|
1
|
1
|
23
|
my $self = shift; |
|
75
|
1
|
|
|
|
|
4
|
return $self->{argref}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 arg() |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
B the scalar argument that the client sent to the job server. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub arg { |
|
85
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
86
|
1
|
|
|
|
|
1
|
return ${ $self->{argref} }; |
|
|
1
|
|
|
|
|
3
|
|
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 handle() |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
B handle |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub handle { |
|
96
|
1
|
|
|
1
|
1
|
478
|
my $self = shift; |
|
97
|
1
|
|
|
|
|
6
|
return $self->{handle}; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|