/usr/share/doc/libcoro-perl/examples/prodcons2 is in libcoro-perl 6.410-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #!/usr/bin/perl
# the classical producer/consumer example, using semaphores
# one process produces items, sends a signal.
# another process waits for that signal and
# consumed the item.
use Coro;
use Coro::Semaphore;
my $produced = new Coro::Semaphore 0;
my $finished = new Coro::Semaphore 0;
async {
for my $i (0..9) {
print "produced $i\n";
push @buffer, $i;
$produced->up;
cede if @buffer > 5; # simulate memory pressure ;)
}
print "work done\n";
$finished->up;
};
async {
while () {
$produced->down;
my $i = shift @buffer;
print "consumed $i\n";
}
};
$finished->down;
print "job finished\n";
|