ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/eg/prodcons3
(Generate patch)

Comparing Coro/eg/prodcons3 (file contents):
Revision 1.1 by root, Tue Jul 10 01:43:21 2001 UTC vs.
Revision 1.4 by root, Mon Nov 6 19:40:02 2006 UTC

1#!/usr/bin/perl 1#!/usr/bin/perl
2 2
3# the classical producer/consumer example, using semaphores 3# the classical producer/consumer example, using a channel
4# one process produces items, send s a signal. 4# one process produces items, sends a signal.
5# another process waits for that signal and 5# another process waits for that signal and
6# consumed the item. 6# consumed the item.
7 7
8use Coro; 8use Coro;
9use Coro::Process;
10use Coro::Channel; 9use Coro::Channel;
11use Coro::Signal; 10use Coro::Signal;
12 11
13my $work = new Coro::Channel 3; 12my $work = new Coro::Channel 3;
14my $finished = new Coro::Signal; 13my $finished = new Coro::Signal;
31 30
32$finished->wait; 31$finished->wait;
33 32
34print "producer finished\n"; 33print "producer finished\n";
35 34
36yield while $work->size; 35cede while $work->size;
37 36
38print "job finished\n"; 37print "job finished\n";
39 38

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines