Skip to content

Commit 1d53b26

Browse files
Light improvements
1 parent 80e29cd commit 1d53b26

File tree

1 file changed

+23
-59
lines changed

1 file changed

+23
-59
lines changed

parse.pl

Lines changed: 23 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ sub instantiate_cached_instance {
494494

495495
#exit if(not $matchinperl);
496496

497-
startmodule(basename($ARGV[-1]) . "_base") if(defined &startmodule and not $nested);
497+
#startmodule(basename($ARGV[-1]) . "_base") if(defined &startmodule and not $nested);
498498

499499
#my $matchprototype = qr{(?(DEFINE)$mainregexdefs)^((??{set {"decls" => "extrnl"}})(?&abstdeclorallqualifs)(??{unset {"decls" => "extrnl"}}))}sxxn;
500500
#my $matchtype = qr{(?(DEFINE)$mainregexdefs)(?&abstdeclorallqualifs)}sxxn;
@@ -568,22 +568,6 @@ sub findnearest {
568568

569569
sub getidtostor {
570570
return pos();
571-
572-
my $ident = $_[0];
573-
my $currpos = pos();
574-
CORE::print("getting for $ident\n");
575-
{
576-
lock $identstoidmap;
577-
return -1 if (not exists $identstoidmap->{$ident});
578-
lock %{$identstoidmap->{$ident}};
579-
#CORE::print("dump " . $ident);
580-
581-
@identscurr = keys %{$identstoidmap->{$ident}};
582-
583-
$idtosignal = (findnearest($currpos, @identscurr, 1))[0];
584-
585-
return $idtosignal
586-
}
587571
}
588572

589573
sub broadcastid {
@@ -592,20 +576,15 @@ sub broadcastid {
592576
my $locker;
593577
#CORE::print("dump " . $ident ."\n");
594578
{
595-
lock $identstoidmap;
596579
#return -1 if (not exists $identstoidmap->{$ident});
597-
lock %{$identstoidmap->{$ident}};
598-
599-
$locker = $identstoidmap->{$ident};
600-
}
601-
{
602-
lock %{$locker};
580+
lock @{$identstoidmap->{$ident}};
603581

604582
CORE::print ("signalling over " . $idtosignal . "\n");
605583

606-
$locker->{$idtosignal} = 1;
584+
push @{$identstoidmap->{$ident}}, $idtosignal;
585+
607586

608-
cond_broadcast(%{$locker})
587+
cond_broadcast(@{$identstoidmap->{$ident}})
609588
}
610589

611590
#CORE::print ("signalling " . $idtosignal . "\n");
@@ -618,50 +597,35 @@ sub waitforid {
618597
my $ident = $_[0];
619598
my @identscur;
620599
my @idtosignal;
621-
my $locker;
622-
623-
{
624-
lock $identstoidmap;
625-
return -1 if (not exists $identstoidmap->{$ident});
626-
#lock %{$identstoidmap->{$ident}};
627-
628-
#CORE::print("dump " . Dumper(\$identstoidmap->{$_[0]}));
629-
630-
#@identscurr = keys %{$identstoidmap->{$ident}};
631-
632-
#@idtosignal = findnearest($currpos, @identscurr, 0);
633-
634-
#return -1 if (not scalar (@idtosignal));
635-
636-
#CORE::print("nearest " . $idtosignal . "\n");
637-
638-
#return -1 if ($idtosignal eq -1);
639-
640-
$locker = $identstoidmap->{$ident};
641-
C#ORE::print("there " . $idtosignal . "\n");
642-
}
600+
my @locker;
643601

644602
while(1)
645603
{
646604

647605
{
648606
#lock $identstoidmap->{$_[0]}->{$idtosignal};
607+
{
608+
609+
lock $identstoidmap;
610+
return -1 if (not exists $identstoidmap->{$ident});
611+
}
649612

650-
lock %{$locker};
613+
lock @{$identstoidmap->{$ident}};
651614

652-
CORE::print("$currpos waitin : " . Dumper2(\%{$locker}));
653615

654-
foreach my $ind (keys %{$locker}) {
655-
CORE::print ("check map $ind \n");
656-
if ($locker->{$ind} and $ind <= $currpos) {
657-
CORE::print ("foind on " . $ident . " - $id\n");
658-
return $ind;
616+
#CORE::print("$currpos waitin : " . Dumper2(\@{$locker}));
617+
618+
foreach my $ind (@{$identstoidmap->{$ident}}) {
619+
CORE::print ("check map $ind \n");
620+
if ($ind <= $currpos) {
621+
CORE::print ("foind on " . $ident . " - $ind\n");
622+
return $ind;
623+
}
659624
}
660-
}
661625

662626
CORE::print ("waitin on " . $ident . "\n");
663627

664-
cond_wait(%{$locker});
628+
cond_wait(@{$identstoidmap->{$ident}});
665629

666630
CORE::print ("end wait on " . $ident . "\n");
667631
}
@@ -1132,7 +1096,7 @@ sub waitforid {
11321096
if ($subject =~ m{$typeorqualifsreg$initseqlight\G(?&brackets)\s*+}sxx) {
11331097
pos($subject) = $+[0];
11341098
lock $identstoidmap;
1135-
$identstoidmap->{$possibleidentlocal} = shared_clone({}) if (not exists $identstoidmap->{$possibleidentlocal});
1099+
$identstoidmap->{$possibleidentlocal} = shared_clone([]) if (not exists $identstoidmap->{$possibleidentlocal});
11361100
#lock %{$identstoidmap->{$possibleidentlocal}};
11371101
#lock $identstoidmap->{$possibleident};
11381102
CORE::print("tag setting $possibleidentlocal @ $lastposend\n");
@@ -1173,7 +1137,7 @@ sub waitforid {
11731137
}
11741138
elsif($possibleident) {
11751139
lock $identstoidmap;
1176-
$identstoidmap->{$possibleident} = shared_clone({}) if (not exists $identstoidmap->{$possibleident});
1140+
$identstoidmap->{$possibleident} = shared_clone([]) if (not exists $identstoidmap->{$possibleident});
11771141
#lock %{$identstoidmap->{$possibleident}};
11781142
#lock $identstoidmap->{$possibleident};
11791143
CORE::print("setting $possibleident - $lastposend\n");

0 commit comments

Comments
 (0)