@@ -567,7 +567,23 @@ sub findnearest {
567
567
}
568
568
569
569
sub getidtostor {
570
- return pos ();
570
+ my $ident = $_ [0];
571
+ my $currpos = pos ();
572
+ my $lastid = -1;
573
+
574
+ {
575
+ # return -1 if (not exists $identstoidmap->{$ident});
576
+ lock @{$identstoidmap -> {$ident }};
577
+
578
+ # CORE::print ("$ident " . Dumper2(\@{$identstoidmap->{$ident}}) . "\n");
579
+
580
+ foreach my $id (@{$identstoidmap -> {$ident }}) {
581
+ CORE::print ($id -> [0] . " against " . $currpos . " \n " );
582
+ last if ($id -> [0] > $currpos );
583
+ $lastid ++;
584
+ }
585
+ }
586
+ return $lastid ;
571
587
}
572
588
573
589
sub broadcastid {
@@ -581,8 +597,7 @@ sub broadcastid {
581
597
582
598
CORE::print (" signalling over " . $idtosignal . " \n " );
583
599
584
- push @{$identstoidmap -> {$ident }}, $idtosignal ;
585
-
600
+ $identstoidmap -> {$ident }-> [$idtosignal ]-> [1] = 1;
586
601
587
602
cond_broadcast(@{$identstoidmap -> {$ident }})
588
603
}
@@ -601,6 +616,8 @@ sub waitforid {
601
616
602
617
while (1)
603
618
{
619
+ my $areallset = 1;
620
+ my $nset = -1;
604
621
605
622
{
606
623
# lock $identstoidmap->{$_[0]}->{$idtosignal};
@@ -613,16 +630,18 @@ sub waitforid {
613
630
lock @{$identstoidmap -> {$ident }};
614
631
615
632
616
- # CORE::print("$currpos waitin : " . Dumper2(\@{$locker }));
633
+ # CORE::print("$currpos waitin : " . Dumper2(\@{$identstoidmap->{$ident} }));
617
634
618
635
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
- }
636
+ # CORE::print ("check map $ind \n");
637
+ last if ( not ($ind -> [0] <= $currpos ));
638
+ $areallset = $areallset && $ind -> [1] ;
639
+ last if ( not $areallset ) ;
640
+ ++ $nset ;
624
641
}
625
642
643
+ return $nset if ($areallset );
644
+
626
645
CORE::print (" waitin on " . $ident . " \n " );
627
646
628
647
cond_wait(@{$identstoidmap -> {$ident }});
@@ -1096,10 +1115,16 @@ sub waitforid {
1096
1115
if ($subject =~ m {$typeorqualifsreg$initseqlight \G (?&brackets)\s *+} sxx ) {
1097
1116
pos ($subject ) = $+ [0];
1098
1117
lock $identstoidmap ;
1099
- $identstoidmap -> {$possibleidentlocal } = shared_clone([]) if (not exists $identstoidmap -> {$possibleidentlocal });
1118
+ if (not exists $identstoidmap -> {$possibleidentlocal }) {
1119
+ $identstoidmap -> {$possibleidentlocal } = shared_clone([[$lastposend , 0]])
1120
+ }
1121
+ else {
1122
+ lock (@{$identstoidmap -> {$possibleidentlocal }});
1123
+ push @{$identstoidmap -> {$possibleidentlocal }}, shared_clone([$lastposend , 0]);
1124
+ }
1100
1125
# lock %{$identstoidmap->{$possibleidentlocal}};
1101
1126
# lock $identstoidmap->{$possibleident};
1102
- CORE::print (" tag setting $possibleidentlocal @ $lastposend \n " );
1127
+ # CORE::print("tag setting $possibleidentlocal @ $lastposend\n");
1103
1128
# $identstoidmap->{$possibleidentlocal}->{(scalar($lastposend))} = 0;
1104
1129
}
1105
1130
$matches [-1]{strc } = 1
@@ -1137,10 +1162,16 @@ sub waitforid {
1137
1162
}
1138
1163
elsif ($possibleident ) {
1139
1164
lock $identstoidmap ;
1140
- $identstoidmap -> {$possibleident } = shared_clone([]) if (not exists $identstoidmap -> {$possibleident });
1165
+ if (not exists $identstoidmap -> {$possibleident }) {
1166
+ $identstoidmap -> {$possibleident } = shared_clone([[$lastposend , 0]])
1167
+ }
1168
+ else {
1169
+ lock (@{$identstoidmap -> {$possibleident }});
1170
+ push @{$identstoidmap -> {$possibleident }}, shared_clone([$lastposend , 0]);
1171
+ }
1141
1172
# lock %{$identstoidmap->{$possibleident}};
1142
1173
# lock $identstoidmap->{$possibleident};
1143
- CORE::print (" setting $possibleident - $lastposend \n " );
1174
+ # CORE::print("setting $possibleident - $lastposend\n");
1144
1175
# $identstoidmap->{$possibleident}->{(scalar($lastposend))} = 0;
1145
1176
register_decl({' ident' => $possibleident , ' typedefkey' => ($matches [-1]{typedefkey })}, 1);
1146
1177
}
0 commit comments