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.15 by root, Fri Nov 30 03:06:37 2001 UTC vs.
Revision 1.18 by root, Sat Dec 1 01:37:24 2001 UTC

9 9
10sub start_transfer { 10sub start_transfer {
11 my $self = shift; 11 my $self = shift;
12 12
13 my $trans = bless [ $self ], 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
45sub wake {
46 my $self = shift;
47 $self->[2] = 1;
48 ref $self->[1] and $self->[1]->ready;
49}
50
48sub try { 51sub try {
49 my $self = shift; 52 my $self = shift;
50 my $timeout = Coro::Timer::timeout $_[0];
51 53
52 unless ($self->[2]) { 54 unless ($self->[2]) {
55 my $timeout = Coro::Timer::timeout $_[0];
53 local $self->[1] = $Coro::current; 56 local $self->[1] = $Coro::current;
57
54 Coro::schedule; 58 Coro::schedule;
55 } 59 }
56 60
57 return $self->[2]; 61 return $self->[2];
58} 62}
59 63
60sub wake {
61 my $self = shift;
62 $self->[2] = 1;
63 ref $self->[1] and $self->[1]->ready;
64}
65
66sub DESTROY { 64sub DESTROY {
67 my $self = shift; 65 my $self = shift;
68 $self->[0]{conns}++; 66 $self->[0]{conns}++;
69 $self->[0]->wake_next; 67 $self->[0]->wake_next if $self->[2];
70} 68}
71 69
72package conn; 70package conn;
73 71
74our %blockuri; 72our %blockuri;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines