Metered concurrency: Difference between revisions

m
m (→‎{{header|Perl 6}}: use xx rather than for loop)
Line 1,025:
{{works with|Rakudo/JVM|2013-11-24}}
Uses a buffered channel to hand out a limited number of tickets.
<lang perl6>class SemaphorSemaphore {
has $.tickets = Channel.new;
method new ($max) {
Line 1,037:
 
sub MAIN ($units = 5, $max = 2) {
my $sem = SemaphorSemaphore.new($max);
 
my @units = do for ^$units -> $u {
Anonymous user