synchronized getAutosensData
This commit is contained in:
parent
2f8ca8bb04
commit
bbc68b2266
1 changed files with 16 additions and 14 deletions
|
@ -522,20 +522,22 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
|
||||
@Nullable
|
||||
public static AutosensData getAutosensData(long time) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (time > now)
|
||||
return null;
|
||||
Long previous = findPreviousTimeFromBucketedData(time);
|
||||
if (previous == null)
|
||||
return null;
|
||||
time = roundUpTime(previous);
|
||||
AutosensData data = autosensDataTable.get(time);
|
||||
if (data != null) {
|
||||
//log.debug(">>> getAutosensData Cache hit " + data.log(time));
|
||||
return data;
|
||||
} else {
|
||||
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
|
||||
return null;
|
||||
synchronized (dataLock) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (time > now)
|
||||
return null;
|
||||
Long previous = findPreviousTimeFromBucketedData(time);
|
||||
if (previous == null)
|
||||
return null;
|
||||
time = roundUpTime(previous);
|
||||
AutosensData data = autosensDataTable.get(time);
|
||||
if (data != null) {
|
||||
//log.debug(">>> getAutosensData Cache hit " + data.log(time));
|
||||
return data;
|
||||
} else {
|
||||
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue