mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-29 23:37:10 +00:00
performance, bug 3380: replacing TrackedRaceImpl.windSourcesToExclude by a ConcurrentHashMap, removing the need to use "synchronized"
This commit is contained in:
1 parent
3fc535963e
commit
8800b22130
1 file changed
+11
-15
+11
-15
@@ -183,7 +183,7 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
|||||||
* By default, all wind sources are used, none are excluded. However, e.g., for performance reasons, particular wind
|
* By default, all wind sources are used, none are excluded. However, e.g., for performance reasons, particular wind
|
||||||
* sources such as the track-based estimation wind source, may be excluded by adding them to this set.
|
* sources such as the track-based estimation wind source, may be excluded by adding them to this set.
|
||||||
*/
|
*/
|
||||||
private final Set<WindSource> windSourcesToExclude;
|
private final ConcurrentHashMap<WindSource, TrackedRaceImpl> windSourcesToExclude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps the oldest timestamp that is fed into this tracked race, either from a boat fix, a mark fix, a race
|
* Keeps the oldest timestamp that is fed into this tracked race, either from a boat fix, a mark fix, a race
|
||||||
@@ -424,7 +424,7 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
|||||||
+ race.getName(), /* fair */ false);
|
+ race.getName(), /* fair */ false);
|
||||||
this.cacheInvalidationTimerLock = new Object();
|
this.cacheInvalidationTimerLock = new Object();
|
||||||
this.updateCount = 0;
|
this.updateCount = 0;
|
||||||
this.windSourcesToExclude = new HashSet<WindSource>();
|
this.windSourcesToExclude = new ConcurrentHashMap<>();
|
||||||
this.directionFromStartToNextMarkCache = new HashMap<TimePoint, Future<Wind>>();
|
this.directionFromStartToNextMarkCache = new HashMap<TimePoint, Future<Wind>>();
|
||||||
this.millisecondsOverWhichToAverageSpeed = millisecondsOverWhichToAverageSpeed;
|
this.millisecondsOverWhichToAverageSpeed = millisecondsOverWhichToAverageSpeed;
|
||||||
this.delayToLiveInMillis = delayToLiveInMillis;
|
this.delayToLiveInMillis = delayToLiveInMillis;
|
||||||
@@ -1679,24 +1679,20 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<WindSource> getWindSourcesToExclude() {
|
public Set<WindSource> getWindSourcesToExclude() {
|
||||||
synchronized (windSourcesToExclude) {
|
return Collections.unmodifiableSet(windSourcesToExclude.keySet());
|
||||||
return Collections.unmodifiableSet(windSourcesToExclude);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWindSourcesToExclude(Iterable<? extends WindSource> windSourcesToExclude) {
|
public void setWindSourcesToExclude(Iterable<? extends WindSource> windSourcesToExclude) {
|
||||||
Set<WindSource> old = new HashSet<>(this.windSourcesToExclude);
|
Set<WindSource> old = new HashSet<>(getWindSourcesToExclude());
|
||||||
synchronized (this.windSourcesToExclude) {
|
LockUtil.lockForRead(getSerializationLock());
|
||||||
LockUtil.lockForRead(getSerializationLock());
|
try {
|
||||||
try {
|
this.windSourcesToExclude.clear();
|
||||||
this.windSourcesToExclude.clear();
|
for (WindSource windSourceToExclude : windSourcesToExclude) {
|
||||||
for (WindSource windSourceToExclude : windSourcesToExclude) {
|
this.windSourcesToExclude.put(windSourceToExclude, this);
|
||||||
this.windSourcesToExclude.add(windSourceToExclude);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
LockUtil.unlockAfterRead(getSerializationLock());
|
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
LockUtil.unlockAfterRead(getSerializationLock());
|
||||||
}
|
}
|
||||||
if (!old.equals(this.windSourcesToExclude)) {
|
if (!old.equals(this.windSourcesToExclude)) {
|
||||||
clearAllCachesExceptManeuvers();
|
clearAllCachesExceptManeuvers();
|
||||||
|
|||||||
Reference in new issue
Block a user