use of com.facebook.buck.util.concurrent.AutoCloseableLock in project buck by facebook.
the class DaemonicParserState method invalidateAllCaches.
public boolean invalidateAllCaches() {
LOG.debug("Starting to invalidate all caches..");
try (AutoCloseableLock writeLock = cellStateLock.writeLock()) {
boolean invalidated = !cellPathToDaemonicState.isEmpty();
cellPathToDaemonicState.clear();
if (invalidated) {
LOG.debug("Cache data invalidated.");
} else {
LOG.debug("Caches were empty, no data invalidated.");
}
return invalidated;
}
}
use of com.facebook.buck.util.concurrent.AutoCloseableLock in project buck by facebook.
the class DaemonicParserState method invalidateContainingBuildFile.
/**
* Finds the build file responsible for the given {@link Path} and invalidates
* all of the cached rules dependent on it.
* @param path A {@link Path}, relative to the project root and "contained"
* within the build file to find and invalidate.
*/
private synchronized void invalidateContainingBuildFile(Cell cell, BuildFileTree buildFiles, Path path) {
LOG.debug("Invalidating rules dependent on change to %s in cell %s", path, cell);
Set<Path> packageBuildFiles = new HashSet<>();
// Find the closest ancestor package for the input path. We'll definitely need to invalidate
// that.
Optional<Path> packageBuildFile = buildFiles.getBasePathOfAncestorTarget(path);
packageBuildFiles.addAll(OptionalCompat.asSet(packageBuildFile.map(cell.getFilesystem()::resolve)));
// packages to reference the same file
if (!cell.isEnforcingBuckPackageBoundaries(path)) {
while (packageBuildFile.isPresent() && packageBuildFile.get().getParent() != null) {
packageBuildFile = buildFiles.getBasePathOfAncestorTarget(packageBuildFile.get().getParent());
packageBuildFiles.addAll(OptionalCompat.asSet(packageBuildFile));
}
}
if (packageBuildFiles.isEmpty()) {
LOG.debug("%s is not owned by any build file. Not invalidating anything.", cell.getFilesystem().resolve(path).toAbsolutePath().toString());
return;
}
buildFilesInvalidatedByFileAddOrRemoveCounter.inc(packageBuildFiles.size());
pathsAddedOrRemovedInvalidatingBuildFiles.add(path.toString());
try (AutoCloseableLock readLock = cellStateLock.readLock()) {
DaemonicCellState state = cellPathToDaemonicState.get(cell.getRoot());
// Invalidate all the packages we found.
for (Path buildFile : packageBuildFiles) {
invalidatePath(state, buildFile.resolve(cell.getBuildFileName()));
}
}
}
Aggregations