mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 12:03:58 +00:00
unified getMarkPassings methods on TrackedRace
Change-Id: Idd4d82766de52a719dae609f5e89f4ec48733fd5
This commit is contained in:
1 parent
3489c9132b
commit
3e163dd6b2
8 files changed
+29
-12
No files matched your search
+1
-1
@@ -1129,7 +1129,7 @@ public class MockedTrackedRace implements DynamicTrackedRace {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableSet<MarkPassing> getUpdatedMarkPassings(Competitor competitor) {
|
||||
public NavigableSet<MarkPassing> getMarkPassings(Competitor competitor, boolean waitForLatestUpdates) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -683,7 +683,7 @@ public class MockedTrackedRaceWithStartTimeAndRanks implements TrackedRace {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableSet<MarkPassing> getUpdatedMarkPassings(Competitor competitor) {
|
||||
public NavigableSet<MarkPassing> getMarkPassings(Competitor competitor, boolean waitForLatestUpdates) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -170,6 +170,13 @@ public class MarkPassingCalculator {
|
||||
*/
|
||||
private class Listen implements Runnable {
|
||||
private final String raceName;
|
||||
|
||||
/**
|
||||
* The write lock is being held by the thread running this {@link Runnable} after successfully having
|
||||
* waited for the next update to be pushed to the {@link MarkPassingUpdateListener#getQueue() queue},
|
||||
* before draining the queue starts and until the processing of all events from the queue has completed.
|
||||
* This way, trying to obtain the read lock will block until all pending updates have been processed.
|
||||
*/
|
||||
private final NamedReentrantReadWriteLock lock;
|
||||
|
||||
public Listen(String raceName) {
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.domain.common.tracking.GPSFix;
|
||||
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.common.tracking.SensorFix;
|
||||
import com.sap.sailing.domain.markpassingcalculation.MarkPassingCalculator;
|
||||
import com.sap.sailing.domain.polars.NotEnoughDataHasBeenAddedException;
|
||||
import com.sap.sailing.domain.polars.PolarDataService;
|
||||
import com.sap.sailing.domain.racelog.tracking.GPSFixStore;
|
||||
@@ -437,10 +438,15 @@ public interface TrackedRace extends Serializable, IsManagedByCache<SharedDomain
|
||||
NavigableSet<MarkPassing> getMarkPassings(Competitor competitor);
|
||||
|
||||
/**
|
||||
* Returns competitor's mark passings after all calculations. The method uses a lock to block the thread until all
|
||||
* calculations will be finished.
|
||||
* Returns competitor's mark passings.
|
||||
*
|
||||
* @param waitForLatestUpdates
|
||||
* if any mark passing updates are pending because some calculations are currently going on and updates
|
||||
* haven't all been processed yet then the call will block until these updates have been processed in
|
||||
* case this parameter is set to {@code true}. For this the method uses a lock on the
|
||||
* {@link MarkPassingCalculator }to block the thread until all calculations will be finished.
|
||||
*/
|
||||
NavigableSet<MarkPassing> getUpdatedMarkPassings(Competitor competitor);
|
||||
NavigableSet<MarkPassing> getMarkPassings(Competitor competitor, boolean waitForLatestUpdates);
|
||||
|
||||
/**
|
||||
* This obtains the course's read lock before asking for the read lock for the <code>markPassings</code> structure.
|
||||
|
||||
+8
-4
@@ -707,16 +707,20 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
||||
|
||||
@Override
|
||||
public NavigableSet<MarkPassing> getMarkPassings(Competitor competitor) {
|
||||
return markPassingsForCompetitor.get(competitor);
|
||||
return getMarkPassings(competitor, /* waitForLatestUpdates */ false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableSet<MarkPassing> getUpdatedMarkPassings(Competitor competitor) {
|
||||
markPassingCalculator.lockForRead();
|
||||
public NavigableSet<MarkPassing> getMarkPassings(Competitor competitor, boolean waitForLatestUpdates) {
|
||||
if (waitForLatestUpdates && markPassingCalculator != null) {
|
||||
markPassingCalculator.lockForRead();
|
||||
}
|
||||
try {
|
||||
return getMarkPassings(competitor);
|
||||
} finally {
|
||||
markPassingCalculator.unlockForRead();
|
||||
if (waitForLatestUpdates && markPassingCalculator != null) {
|
||||
markPassingCalculator.unlockForRead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -862,7 +862,7 @@ public class MockedTrackedRace implements DynamicTrackedRace {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableSet<MarkPassing> getUpdatedMarkPassings(Competitor competitor) {
|
||||
public NavigableSet<MarkPassing> getMarkPassings(Competitor competitor, boolean waitForLatestUpdates) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5812,7 +5812,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
Competitor competitor = getCompetitorByIdAsString(trackedRace.getRace().getCompetitors(), competitorDTO.getIdAsString());
|
||||
Set<MarkPassing> competitorMarkPassings;
|
||||
if (waitForCalculations) {
|
||||
competitorMarkPassings = trackedRace.getUpdatedMarkPassings(competitor);
|
||||
competitorMarkPassings = trackedRace.getMarkPassings(competitor, /* waitForLatestUpdates */ true);
|
||||
} else {
|
||||
competitorMarkPassings = trackedRace.getMarkPassings(competitor);
|
||||
}
|
||||
|
||||
+1
-1
@@ -664,7 +664,7 @@ public class DummyTrackedRace extends TrackedRaceWithWindEssentials {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableSet<MarkPassing> getUpdatedMarkPassings(Competitor competitor) {
|
||||
public NavigableSet<MarkPassing> getMarkPassings(Competitor competitor, boolean waitForLatestUpdates) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user