Skip to content

Instantly share code, notes, and snippets.

View autarch's full-sized avatar

Dave Rolsky autarch

View GitHub Profile
method !run-with-progress ($items, Routine $sub, Str $msg = q{ done}) {
my $prog = Term::ProgressBar.new( :count( $items.elems ), :p )
if $!verbose;
my $i = 1;
my $supply = $items.Supply.throttle(
$!threads,
-> $item {
say "$i = $item in {$*THREAD.id}";
method !run-with-progress ($items, Routine $sub, Str $msg = q{ done}) {
my $prog = Term::ProgressBar.new( :count( $items.elems ), :p )
if $!verbose;
my $i = 1;
$items.hyper( :batch($!threads) ).map(
sub ($item) {
say $item;return;
$sub($item);
method !run-with-progress ($items, Routine $sub, Str $msg = q{ done}) {
my $prog = Term::ProgressBar.new( :count( $items.elems ), :p )
if $!verbose;
my $supply = $items.Supply;
if $!threads > 1 {
my $sched = ThreadPoolScheduler.new( :max_threads($!threads) );
$supply = $supply.schedule-on($sched);
#!/usr/bin/env perl6
use v6;
sub MAIN {
my $supply = (1, 2, 3, 4, 5).Supply;
my $sched = ThreadPoolScheduler.new(
:initial_threads(4),
:max_threads(8),
);
my $sched = ThreadPoolScheduler
.new( :max_threads($!threads) );
my $supply = $items.values.Supply;
$supply.schedule-on($sched);
my $i = 1;
$supply.tap(
sub ($item) {
$sub($item);
use v6;
use File::Temp;
(1..100).hyper(:batch(1)).map( { tempfile() } );
# Use of Nil in string context in block at /home/autarch/.rakudobrew/moar-nom/install/share/perl6/site/lib/File/Temp.pm:15
=begin pod
=defn Item
Definition
=end pod
dd $=pod;
role R {
multi method foo (Any $foo) { ... }
}
class C does R {
multi method foo (Any $foo) { say $foo }
}
C.new.foo(42)
sub heading (Pod::Heading $node) {
my $tag = 'h' . $node.level;
$!html .= "<$tag>";
yield;
$!thml .= "</tag>";
}
use v6;
use Text::CSV;
sub MAIN ( IO() :$in, IO() :$out ) {
my $csv_in = Text::CSV.new;
my $csv_out = Text::CSV.new( :eol("\r\n") );
my $in_fh = $in.open(:r);
my $out_fh = $out.open(:w);