ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Coro/eg/prodcons1
Revision: 1.2
Committed: Sun Jul 15 02:35:52 2001 UTC (22 years, 11 months ago) by root
Branch: MAIN
Changes since 1.1: +0 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/usr/bin/perl
2    
3     # the classical producer/consumer example.
4     # one process produces items, send s a signal.
5     # another process waits for that signal and
6     # consumed the item.
7    
8     use Coro;
9     use Coro::Signal;
10    
11     my $produced = new Coro::Signal;
12     my $consumed = new Coro::Signal;
13     my $finished = new Coro::Signal;
14    
15     async {
16     for (0..9) {
17     print "produced something\n";
18     $produced->send;
19     $consumed->wait;
20     }
21     print "work done\n";
22     $finished->send;
23     $idle;
24     };
25    
26     async {
27     while () {
28     $produced->wait;
29     print "consuming something\n";
30     $consumed->send;
31     }
32     };
33    
34     $finished->wait;
35    
36     print "job finished\n";
37