Skip to content

Commit c586bd6

Browse files
committed
PUblish timetable snapshot with ConcurrentPublished
1 parent 533724c commit c586bd6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/java/org/opentripplanner/updater/trip/TimetableSnapshotManager.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.opentripplanner.model.Timetable;
99
import org.opentripplanner.model.TimetableSnapshot;
1010
import org.opentripplanner.routing.algorithm.raptoradapter.transit.mappers.TransitLayerUpdater;
11+
import org.opentripplanner.routing.util.ConcurrentPublished;
1112
import org.opentripplanner.transit.model.framework.FeedScopedId;
1213
import org.opentripplanner.transit.model.framework.Result;
1314
import org.opentripplanner.transit.model.network.TripPattern;
@@ -38,9 +39,9 @@ public final class TimetableSnapshotManager {
3839

3940
/**
4041
* The last committed snapshot that was handed off to a routing thread. This snapshot may be given
41-
* to more than one routing thread if the maximum snapshot frequency is exceeded.
42+
* to more than one routing thread.
4243
*/
43-
private volatile TimetableSnapshot snapshot = null;
44+
private final ConcurrentPublished<TimetableSnapshot> snapshot = new ConcurrentPublished<>();
4445

4546
/**
4647
* If a timetable snapshot is requested less than this number of milliseconds after the previous
@@ -87,7 +88,7 @@ public TimetableSnapshotManager(
8788
* to the snapshot to release resources.
8889
*/
8990
public TimetableSnapshot getTimetableSnapshot() {
90-
return snapshot;
91+
return snapshot.get();
9192
}
9293

9394
public TimetableSnapshot getTimetableSnapshotBuffer() {
@@ -106,7 +107,7 @@ void commitTimetableSnapshot(final boolean force) {
106107
if (force || snapshotFrequencyThrottle.timeIsUp()) {
107108
if (force || buffer.isDirty()) {
108109
LOG.debug("Committing {}", buffer);
109-
snapshot = buffer.commit(transitLayerUpdater, force);
110+
snapshot.publish(buffer.commit(transitLayerUpdater, force));
110111

111112
// We only reset the timer when the snapshot is updated. This will cause the first
112113
// update to be committed after a silent period. This should not have any effect in

0 commit comments

Comments
 (0)