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

Comparing cvsroot/Coro/myhttpd/access.pl (file contents):
Revision 1.14 by root, Fri Nov 30 03:02:23 2001 UTC vs.
Revision 1.18 by root, Sat Dec 1 01:37:24 2001 UTC

8} 8}
9 9
10sub start_transfer { 10sub start_transfer {
11 my $self = shift; 11 my $self = shift;
12 12
13 my $trans = bless [ $self, $Coro::current ], transfer::; 13 my $trans = bless [ $self ], transfer::;
14 Scalar::Util::weaken($trans->[0]);
15 14
16 push @{$self->{wait}}, $trans; 15 push @{$self->{wait}}, $trans;
17 Scalar::Util::weaken($self->{wait}[-1]); 16 Scalar::Util::weaken($self->{wait}[-1]);
18 17
19 if (--$self->{conns} >= 0) { 18 if (--$self->{conns} >= 0) {
24} 23}
25 24
26sub wake_next { 25sub wake_next {
27 my $self = shift; 26 my $self = shift;
28 27
29 if ($self->{conns} >= 0) {
30 while(@{$self->{wait}}) { 28 while(@{$self->{wait}}) {
31 my $transfer = shift @{$self->{wait}}; 29 my $transfer = shift @{$self->{wait}};
32 if ($transfer) { 30 if ($transfer) {
33 $transfer->wake; 31 $transfer->wake;
34 last; 32 last;
35 }
36 } 33 }
37 } 34 }
38} 35}
39 36
40sub waiters { 37sub waiters {
43 40
44package transfer; 41package transfer;
45 42
46use Coro::Timer (); 43use Coro::Timer ();
47 44
48sub try {
49 my $self = shift;
50 my $timeout = Coro::Timer::timeout $_[0];
51
52 $self->[2] or Coro::schedule;
53
54 return $self->[2];
55}
56
57sub wake { 45sub wake {
58 my $self = shift; 46 my $self = shift;
59 $self->[2] = 1; 47 $self->[2] = 1;
60 $self->[1]->ready; 48 ref $self->[1] and $self->[1]->ready;
49}
50
51sub try {
52 my $self = shift;
53
54 unless ($self->[2]) {
55 my $timeout = Coro::Timer::timeout $_[0];
56 local $self->[1] = $Coro::current;
57
58 Coro::schedule;
59 }
60
61 return $self->[2];
61} 62}
62 63
63sub DESTROY { 64sub DESTROY {
64 my $self = shift; 65 my $self = shift;
65 $self->[0]{conns}++; 66 $self->[0]{conns}++;
66 $self->[0]->wake_next; 67 $self->[0]->wake_next if $self->[2];
67} 68}
68 69
69package conn; 70package conn;
70 71
71our %blockuri; 72our %blockuri;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines