Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 2297343002: Flush results when contexts are made idle. (Closed)
Patch Set: Un-fail completion tests. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/context/cache.dart
diff --git a/pkg/analyzer/lib/src/context/cache.dart b/pkg/analyzer/lib/src/context/cache.dart
index 532764f3b662736857a6520f0a40792278c15a66..74bd8aa1973837aba504e8be5fe1c003bf2600f5 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -940,7 +940,7 @@ class CacheFlushManager<T> {
: policy = policy,
maxActiveSize = policy.maxActiveSize,
maxIdleSize = policy.maxIdleSize,
- maxSize = policy.maxIdleSize;
+ maxSize = policy.maxActiveSize;
/**
* If [currentSize] is already less than [maxSize], returns an empty list.
@@ -1081,6 +1081,20 @@ abstract class CachePartition {
CachePartition(this.context);
/**
+ * Specify whether a context that uses this partition is being analyzed.
+ */
+ set isActive(bool active) {
+ for (CacheFlushManager manager in _flushManagerMap.values) {
+ if (active) {
+ manager.madeActive();
+ } else {
+ List<TargetedResult> resultsToFlush = manager.madeIdle();
+ _flushResults(resultsToFlush);
+ }
+ }
+ }
+
+ /**
* Notifies the partition that the client is going to stop using it.
*/
void dispose() {
@@ -1176,15 +1190,7 @@ abstract class CachePartition {
CacheFlushManager flushManager = _getFlushManager(result.result);
List<TargetedResult> resultsToFlush =
flushManager.resultStored(result, value);
- for (TargetedResult result in resultsToFlush) {
- CacheEntry entry = get(result.target);
- if (entry != null) {
- ResultData data = entry._resultMap[result.result];
- if (data != null) {
- data.flush();
- }
- }
- }
+ _flushResults(resultsToFlush);
}
/**
@@ -1204,6 +1210,21 @@ abstract class CachePartition {
}
/**
+ * Flush the given [resultsToFlush].
+ */
+ void _flushResults(List<TargetedResult> resultsToFlush) {
+ for (TargetedResult result in resultsToFlush) {
+ CacheEntry entry = get(result.target);
+ if (entry != null) {
+ ResultData data = entry._resultMap[result.result];
+ if (data != null) {
+ data.flush();
+ }
+ }
+ }
+ }
+
+ /**
* Return the [CacheFlushManager] for the given [descriptor], not `null`.
*/
CacheFlushManager _getFlushManager(ResultDescriptor descriptor) {
« no previous file with comments | « pkg/analysis_server/lib/src/operation/operation_analysis.dart ('k') | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698