wip
This commit is contained in:
parent
d0ff801e7d
commit
ff1745df3a
13
day07/run.pl
13
day07/run.pl
|
|
@ -49,13 +49,13 @@ for(my $y=0; $y<@lines; $y++) {
|
|||
}
|
||||
|
||||
my $ends = 0;
|
||||
my $numworkers = 16;
|
||||
my $numworkers = $ARGV[0] || 16;
|
||||
my $queue = Thread::Queue->new();
|
||||
my @threads;
|
||||
|
||||
$queue->enqueue($startpos);
|
||||
for(my $i=0; $i<$numworkers; $i++) {
|
||||
push @threads, threads->create(\&process);
|
||||
push @threads, threads->create(\&process, $i);
|
||||
}
|
||||
|
||||
foreach my $thread (@threads) {
|
||||
|
|
@ -66,8 +66,12 @@ foreach my $thread (@threads) {
|
|||
print "$ends total ends\n";
|
||||
|
||||
sub process {
|
||||
my $threadid=shift(@_);
|
||||
my $ends = 0;
|
||||
while(my $pos=$queue->dequeue_timed(5)) {
|
||||
if($threadid == 0) {
|
||||
print $queue->pending() . " pending\n";
|
||||
}
|
||||
my($x,$y)=@$pos;
|
||||
|
||||
for(;;) {
|
||||
|
|
@ -77,8 +81,9 @@ sub process {
|
|||
last;
|
||||
} elsif($rows[$x][$y] eq '^') {
|
||||
$queue->enqueue([$x-1, $y]);
|
||||
$queue->enqueue([$x+1, $y]);
|
||||
last;
|
||||
$x++;
|
||||
#$queue->enqueue([$x+1, $y]);
|
||||
#last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue