Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 31 lines (27 sloc) 0.654 kb
8db95e7 @tokuhirom initial import
authored
1 use strict;
2 use warnings;
3 use Coro;
4 use Coro::Socket;
5 use Coro::Semaphore;
6 use Getopt::Long;
7
8 my $concurrent = 10;
9 my $port = 9010;
10 GetOptions(
11 'concurrent=s' => \$concurrent,
12 );
13
14 print "coro: http://localhost:9010/\n";
15 print "concurrency: $concurrent\n";
16 my $sock = Coro::Socket->new(LocalHost => 'localhost', LocalPort => $port, Listen => 10, ReuseAddr => 1);
17 my @coros;
18 for my $i (1..$concurrent) {
19 print "awake thread $i\n";
20 push @coros, async {
21 while (1) {
15f1f86 @tokuhirom remove lock
authored
22 my $csock = $sock->accept;
8db95e7 @tokuhirom initial import
authored
23 while (my $line = <$csock>) {
24 print $csock $line;
25 }
26 }
27 };
28 }
29 $_->join for @coros;
30
Something went wrong with that request. Please try again.