make driver space cache lazy to relax init order

This commit is contained in:
Jonathan Shook 2021-12-20 10:03:23 -06:00
parent c001c117fe
commit 66c07a0ae3

View File

@ -14,14 +14,12 @@ import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public abstract class BaseDriverAdapter<R extends Op,S> public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter<R,S>, NBConfigurable {
implements DriverAdapter<R,S>, NBConfigurable {
private final DriverSpaceCache<? extends S> spaceCache; private DriverSpaceCache<? extends S> spaceCache;
private NBConfiguration cfg; private NBConfiguration cfg;
protected BaseDriverAdapter() { protected BaseDriverAdapter() {
this.spaceCache = new DriverSpaceCache<>(getSpaceInitializer(getConfiguration()));
} }
/** /**
@ -83,7 +81,10 @@ public abstract class BaseDriverAdapter<R extends Op,S>
} }
@Override @Override
public final DriverSpaceCache<? extends S> getSpaceCache() { public synchronized final DriverSpaceCache<? extends S> getSpaceCache() {
if (spaceCache==null) {
spaceCache=new DriverSpaceCache<>(getSpaceInitializer(getConfiguration()));
}
return spaceCache; return spaceCache;
} }