8
8
import org .opentripplanner .model .Timetable ;
9
9
import org .opentripplanner .model .TimetableSnapshot ;
10
10
import org .opentripplanner .routing .algorithm .raptoradapter .transit .mappers .TransitLayerUpdater ;
11
+ import org .opentripplanner .routing .util .ConcurrentPublished ;
11
12
import org .opentripplanner .transit .model .framework .FeedScopedId ;
12
13
import org .opentripplanner .transit .model .framework .Result ;
13
14
import org .opentripplanner .transit .model .network .TripPattern ;
@@ -38,9 +39,9 @@ public final class TimetableSnapshotManager {
38
39
39
40
/**
40
41
* 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.
42
43
*/
43
- private volatile TimetableSnapshot snapshot = null ;
44
+ private final ConcurrentPublished < TimetableSnapshot > snapshot = new ConcurrentPublished <>() ;
44
45
45
46
/**
46
47
* If a timetable snapshot is requested less than this number of milliseconds after the previous
@@ -87,7 +88,7 @@ public TimetableSnapshotManager(
87
88
* to the snapshot to release resources.
88
89
*/
89
90
public TimetableSnapshot getTimetableSnapshot () {
90
- return snapshot ;
91
+ return snapshot . get () ;
91
92
}
92
93
93
94
public TimetableSnapshot getTimetableSnapshotBuffer () {
@@ -106,7 +107,7 @@ void commitTimetableSnapshot(final boolean force) {
106
107
if (force || snapshotFrequencyThrottle .timeIsUp ()) {
107
108
if (force || buffer .isDirty ()) {
108
109
LOG .debug ("Committing {}" , buffer );
109
- snapshot = buffer .commit (transitLayerUpdater , force );
110
+ snapshot . publish ( buffer .commit (transitLayerUpdater , force ) );
110
111
111
112
// We only reset the timer when the snapshot is updated. This will cause the first
112
113
// update to be committed after a silent period. This should not have any effect in
0 commit comments