| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#********************************************************************* |
|
2
|
|
|
|
|
|
|
#*** ResourcePool::LoadBalancer::RoundRobin |
|
3
|
|
|
|
|
|
|
#*** Copyright (c) 2002,2003 by Markus Winand |
|
4
|
|
|
|
|
|
|
#*** $Id: RoundRobin.pm,v 1.11 2013-04-16 10:14:44 mws Exp $ |
|
5
|
|
|
|
|
|
|
#********************************************************************* |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package ResourcePool::LoadBalancer::RoundRobin; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
67
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use ResourcePool::LoadBalancer; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
368
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = "1.0107"; |
|
13
|
|
|
|
|
|
|
push @ISA, "ResourcePool::LoadBalancer"; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_once($) { |
|
16
|
10
|
|
|
10
|
0
|
15
|
my ($self) = @_; |
|
17
|
10
|
|
|
|
|
11
|
my $rec; |
|
18
|
|
|
|
|
|
|
my $r_pool; |
|
19
|
|
|
|
|
|
|
|
|
20
|
10
|
|
|
|
|
18
|
$r_pool = $self->{PoolArray}->[$self->{Next}++]; |
|
21
|
10
|
100
|
|
|
|
14
|
if ($self->{Next} >= scalar(@{$self->{PoolArray}})) { |
|
|
10
|
|
|
|
|
24
|
|
|
22
|
5
|
|
|
|
|
8
|
$self->{Next} = 0; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
10
|
100
|
|
|
|
32
|
if (! $self->chk_suspend($r_pool)) { |
|
25
|
7
|
|
|
|
|
19
|
$rec = $r_pool->{pool}->get(); |
|
26
|
7
|
100
|
|
|
|
89
|
if (! defined $rec) { |
|
27
|
2
|
|
|
|
|
20
|
$self->suspend($r_pool); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
} |
|
30
|
10
|
100
|
|
|
|
27
|
if ( $self->chk_suspend($r_pool)) { |
|
31
|
5
|
|
|
|
|
6
|
undef $rec; |
|
32
|
5
|
|
|
|
|
7
|
undef $r_pool; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
10
|
|
|
|
|
208
|
return ($rec, $r_pool); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |