ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/access.pl
(Generate patch)

Comparing Coro/myhttpd/access.pl (file contents):
Revision 1.19 by root, Mon Dec 3 04:57:22 2001 UTC vs.
Revision 1.20 by root, Mon Dec 3 05:40:09 2001 UTC

3sub new { 3sub new {
4 my $class = shift; 4 my $class = shift;
5 bless { 5 bless {
6 slots => $_[0], 6 slots => $_[0],
7 lastspb => 0, 7 lastspb => 0,
8 avgspb => 0,
8 }, $class; 9 }, $class;
9} 10}
10 11
11sub start_transfer { 12sub start_transfer {
12 my $self = shift; 13 my $self = shift;
13 my $size = $_[0]; 14 my $size = $_[0];
14 15
15 my $trans = bless { 16 my $transfer = bless {
16 queue => $self, 17 queue => $self,
17 time => $::NOW, 18 time => $::NOW,
18 size => $size, 19 size => $size,
19 coro => $Coro::current, 20 coro => $Coro::current,
20 }, transfer::; 21 }, transfer::;
21 22
22 push @{$self->{wait}}, $trans; 23 push @{$self->{wait}}, $transfer;
23 Scalar::Util::weaken($self->{wait}[-1]); 24 Scalar::Util::weaken($self->{wait}[-1]);
24 25
25 $self->wake_next; 26 $self->wake_next;
26 27
27 $trans; 28 $trans;
34 35
35 while($self->{slots} && @{$self->{wait}}) { 36 while($self->{slots} && @{$self->{wait}}) {
36 my $transfer = shift @{$self->{wait}}; 37 my $transfer = shift @{$self->{wait}};
37 if ($transfer) { 38 if ($transfer) {
38 $self->{lastspb} = $transfer->{spb}; 39 $self->{lastspb} = $transfer->{spb};
40 $self->{avgspb} ||= $transfer->{spb};
41 $self->{avgspb} = $self->{avgspb} * 0.95 + $transfer->{spb} * 0.05;
39 $transfer->wake; 42 $transfer->wake;
40 last; 43 last;
41 } 44 }
42 } 45 }
43} 46}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines