java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java
... ...
@@ -32,7 +32,6 @@ import java.util.concurrent.Callable;
32 32
import java.util.concurrent.ConcurrentHashMap;
33 33
import java.util.concurrent.ConcurrentMap;
34 34
import java.util.concurrent.ConcurrentSkipListSet;
35
-import java.util.concurrent.CountDownLatch;
36 35
import java.util.concurrent.ExecutionException;
37 36
import java.util.concurrent.Future;
38 37
import java.util.concurrent.FutureTask;
... ...
@@ -147,13 +146,13 @@ import com.sap.sailing.domain.racelog.RaceLogAndTrackedRaceResolver;
147 146
import com.sap.sailing.domain.ranking.OneDesignRankingMetric;
148 147
import com.sap.sailing.domain.ranking.RankingMetric;
149 148
import com.sap.sailing.domain.ranking.RankingMetric.RankingInfo;
149
+import com.sap.sailing.domain.ranking.RankingMetricConstructor;
150 150
import com.sap.sailing.domain.shared.tracking.AddResult;
151 151
import com.sap.sailing.domain.shared.tracking.LineDetails;
152 152
import com.sap.sailing.domain.shared.tracking.Track;
153 153
import com.sap.sailing.domain.shared.tracking.TrackingConnectorInfo;
154 154
import com.sap.sailing.domain.shared.tracking.impl.LineDetailsImpl;
155 155
import com.sap.sailing.domain.shared.tracking.impl.TimedComparator;
156
-import com.sap.sailing.domain.ranking.RankingMetricConstructor;
157 156
import com.sap.sailing.domain.tracking.BravoFixTrack;
158 157
import com.sap.sailing.domain.tracking.DynamicSensorFixTrack;
159 158
import com.sap.sailing.domain.tracking.GPSFixTrack;
... ...
@@ -3112,36 +3111,33 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
3112 3111
}
3113 3112
3114 3113
public void waitForAllRaceLogsAttached() {
3115
- final CountDownLatch latchForRaceLogs = new CountDownLatch(1); // Alternatives possible
3116
- final Iterable<Triple<Leaderboard, RaceColumn, Fleet>> ecpextedLinks = TrackedRaceImpl.this.getRaceLogResolver()
3117
- .getColumnsWithRaceLogForTrackedRace(getRaceIdentifier()); //Namen
3118
- final int numberOfExpectedRaceLogs = Util.size(ecpextedLinks);
3119
-
3120
- AbstractRaceChangeListener raceLogAttachedListener = new AbstractRaceChangeListener() {
3121
-
3122
- @Override
3123
- public void raceLogAttached(RaceLog raceLog) {
3124
- int numberOfAttachedRaceLogs = Util.size(getAttachedRaceLogs());
3125
- if(numberOfAttachedRaceLogs >=numberOfExpectedRaceLogs) {
3126
- latchForRaceLogs.countDown();
3127
- }
3128
- }
3129
- };
3130
-
3114
+ final Object latchForRaceLogs = new Object();
3115
+ final Iterable<Triple<Leaderboard, RaceColumn, Fleet>> expectedLinks = TrackedRaceImpl.this.getRaceLogResolver()
3116
+ .getColumnsWithRaceLogForTrackedRace(getRaceIdentifier());
3117
+ final int numberOfExpectedRaceLogs = Util.size(expectedLinks);
3118
+ final AbstractRaceChangeListener raceLogAttachedListener = new AbstractRaceChangeListener() {
3119
+ @Override
3120
+ public void raceLogAttached(RaceLog raceLog) {
3121
+ int numberOfAttachedRaceLogs = Util.size(getAttachedRaceLogs());
3122
+ synchronized (latchForRaceLogs) {
3123
+ if (numberOfAttachedRaceLogs >= numberOfExpectedRaceLogs) {
3124
+ latchForRaceLogs.notifyAll();
3125
+ }
3126
+ }
3127
+ }
3128
+ };
3131 3129
this.addListener(raceLogAttachedListener);
3132
-
3133 3130
final int numberOfAttachedRaceLogs = Util.size(getAttachedRaceLogs());
3134
-
3135 3131
try {
3136
- if (numberOfAttachedRaceLogs < numberOfExpectedRaceLogs) {
3137
- latchForRaceLogs.await();
3138
- }
3132
+ synchronized (latchForRaceLogs) {
3133
+ while (numberOfAttachedRaceLogs < numberOfExpectedRaceLogs) {
3134
+ latchForRaceLogs.wait();
3135
+ }
3136
+ }
3139 3137
} catch (InterruptedException e) {
3140
- // TODO Auto-generated catch block
3141
- //Logging hinzufügen
3142
- e.printStackTrace();
3138
+ logger.warning("Interrupted: "+e.getMessage());
3143 3139
} finally {
3144
- removeListener(raceLogAttachedListener);
3140
+ removeListener(raceLogAttachedListener);
3145 3141
}
3146 3142
}
3147 3143
... ...
@@ -3222,7 +3218,6 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
3222 3218
attachedRaceLogs.put(raceLog.getId(), raceLog);
3223 3219
notifyAll();
3224 3220
invalidateStartTime();
3225
-
3226 3221
}
3227 3222
notifyListenersWhenAttachingRaceLog(raceLog);
3228 3223
}