line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::STAF;
|
2
|
3
|
|
|
3
|
|
2146
|
use strict;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
116
|
|
3
|
3
|
|
|
3
|
|
5060
|
use threads::shared;
|
|
3
|
|
|
|
|
4557
|
|
|
3
|
|
|
|
|
20
|
|
4
|
3
|
|
|
3
|
|
2259
|
use Class::STAF::Marshalled qw(:all);
|
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
1187
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.02;
|
7
|
|
|
|
|
|
|
our @ISA = qw{Exporter};
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw{
|
10
|
|
|
|
|
|
|
Marshall
|
11
|
|
|
|
|
|
|
UnMarshall
|
12
|
|
|
|
|
|
|
};
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw{
|
15
|
|
|
|
|
|
|
get_staf_fields
|
16
|
|
|
|
|
|
|
get_staf_class_name
|
17
|
|
|
|
|
|
|
};
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %thread_ref_count;
|
20
|
|
|
|
|
|
|
my $id_counter = 1;
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new {
|
23
|
1
|
|
|
1
|
0
|
20
|
my ($class, $processName) = @_;
|
24
|
1
|
|
|
|
|
14
|
require PLSTAF;
|
25
|
1
|
|
|
|
|
11
|
my $handle = STAF::STAFHandle->new($processName);
|
26
|
1
|
50
|
|
|
|
23
|
if ($handle->{rc} != $STAF::kOk) {
|
27
|
0
|
|
|
|
|
0
|
$! = $handle->{rc};
|
28
|
0
|
|
|
|
|
0
|
return;
|
29
|
|
|
|
|
|
|
}
|
30
|
3
|
|
|
3
|
|
4293
|
my $refcount : shared = 1;
|
|
3
|
|
|
|
|
5282
|
|
|
3
|
|
|
|
|
3283
|
|
|
1
|
|
|
|
|
12
|
|
31
|
1
|
|
|
|
|
44
|
my $key = $id_counter++;
|
32
|
1
|
|
|
|
|
5
|
$thread_ref_count{$key} = \$refcount;
|
33
|
1
|
|
|
|
|
8
|
return bless {handle => $handle, refcount => $key}, $class;
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub CLONE {
|
37
|
0
|
|
|
0
|
|
0
|
foreach (values %thread_ref_count) {
|
38
|
0
|
|
|
|
|
0
|
lock $$_;
|
39
|
0
|
|
|
|
|
0
|
$$_++;
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub submit {
|
44
|
3
|
|
|
3
|
0
|
836
|
my ($self, $location, $service, $request) = @_;
|
45
|
3
|
|
|
|
|
13
|
my $result = $self->{handle}->submit($location, $service, $request);
|
46
|
3
|
50
|
|
|
|
30
|
if ($result->{rc} != $STAF::kOk) {
|
47
|
0
|
|
|
|
|
0
|
$! = $result->{rc};
|
48
|
0
|
|
|
|
|
0
|
$self->{LastError} = $result->{result};
|
49
|
0
|
|
|
|
|
0
|
return;
|
50
|
|
|
|
|
|
|
}
|
51
|
3
|
|
|
|
|
21
|
return $result->{result};
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub submit2 {
|
55
|
1
|
|
|
1
|
0
|
5
|
my ($self, $syncOption, $location, $service, $request) = @_;
|
56
|
1
|
|
|
|
|
6
|
my $result = $self->{handle}->submit2($syncOption, $location, $service, $request);
|
57
|
1
|
50
|
|
|
|
15
|
if ($result->{rc} != $STAF::kOk) {
|
58
|
0
|
|
|
|
|
0
|
$! = $result->{rc};
|
59
|
0
|
|
|
|
|
0
|
$self->{LastError} = $result->{result};
|
60
|
0
|
|
|
|
|
0
|
return;
|
61
|
|
|
|
|
|
|
}
|
62
|
1
|
|
|
|
|
7
|
return $result->{result};
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub host {
|
66
|
2
|
|
|
2
|
0
|
4
|
my ($self, $hostname) = @_;
|
67
|
2
|
|
|
|
|
12
|
return Class::STAF::Host->new($self, $hostname);
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub LastError {
|
71
|
0
|
|
|
0
|
0
|
0
|
my $self = shift;
|
72
|
0
|
|
|
|
|
0
|
return $self->{LastError};
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub DESTROY {
|
76
|
1
|
|
|
1
|
|
2
|
my $self = shift;
|
77
|
1
|
|
|
|
|
3
|
my $key = $self->{refcount};
|
78
|
|
|
|
|
|
|
{
|
79
|
1
|
|
|
|
|
1
|
my $ref = $thread_ref_count{$key};
|
|
1
|
|
|
|
|
4
|
|
80
|
1
|
|
|
|
|
2
|
lock $$ref;
|
81
|
1
|
|
|
|
|
2
|
$$ref--;
|
82
|
1
|
|
|
|
|
2
|
delete $thread_ref_count{$key};
|
83
|
1
|
50
|
|
|
|
5
|
return unless $$ref == 0;
|
84
|
|
|
|
|
|
|
}
|
85
|
1
|
|
|
|
|
5
|
my $rc = $self->{handle}->unRegister();
|
86
|
1
|
50
|
|
|
|
17
|
if ($rc != $STAF::kOk) {
|
87
|
0
|
|
|
|
|
0
|
warn "Failed to unRegister from STAF";
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
package # hide?
|
92
|
|
|
|
|
|
|
Class::STAF::Host;
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub new {
|
95
|
2
|
|
|
2
|
|
3
|
my ($class, $parent, $hostname) = @_;
|
96
|
2
|
|
|
|
|
8
|
my $self = { Parent => $parent, Host => $hostname };
|
97
|
2
|
|
|
|
|
145
|
return bless $self, $class;
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub submit {
|
101
|
1
|
|
|
1
|
|
3
|
my ($self, $service, $request) = @_;
|
102
|
1
|
|
|
|
|
10
|
return $self->{Parent}->submit($self->{Host}, $service, $request);
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub submit2 {
|
106
|
0
|
|
|
0
|
|
0
|
my ($self, $syncOption, $service, $request) = @_;
|
107
|
0
|
|
|
|
|
0
|
return $self->{Parent}->submit2($syncOption, $self->{Host}, $service, $request);
|
108
|
|
|
|
|
|
|
}
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub LastError {
|
111
|
0
|
|
|
0
|
|
0
|
my $self = shift;
|
112
|
0
|
|
|
|
|
0
|
return $self->{Parent}->{LastError};
|
113
|
|
|
|
|
|
|
}
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub service {
|
116
|
1
|
|
|
1
|
|
2
|
my ($self, $service) = @_;
|
117
|
1
|
|
|
|
|
8
|
return Class::STAF::Service->new($self->{Parent}, $self->{Host}, $service);
|
118
|
|
|
|
|
|
|
}
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
package # hide?
|
121
|
|
|
|
|
|
|
Class::STAF::Service;
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub new {
|
124
|
1
|
|
|
1
|
|
2
|
my ($class, $parent, $hostname, $service) = @_;
|
125
|
1
|
|
|
|
|
12
|
my $self = { Parent => $parent, Host => $hostname, Service => $service };
|
126
|
1
|
|
|
|
|
6
|
return bless $self, $class;
|
127
|
|
|
|
|
|
|
}
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub submit {
|
130
|
1
|
|
|
1
|
|
7
|
my ($self, $request) = @_;
|
131
|
1
|
|
|
|
|
9
|
return $self->{Parent}->submit($self->{Host}, $self->{Service}, $request);
|
132
|
|
|
|
|
|
|
}
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub submit2 {
|
135
|
0
|
|
|
0
|
|
|
my ($self, $syncOption, $request) = @_;
|
136
|
0
|
|
|
|
|
|
return $self->{Parent}->submit2($syncOption, $self->{Host}, $self->{Service}, $request);
|
137
|
|
|
|
|
|
|
}
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub LastError {
|
140
|
0
|
|
|
0
|
|
|
my $self = shift;
|
141
|
0
|
|
|
|
|
|
return $self->{Parent}->{LastError};
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1;
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
__END__
|