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

Unified Diff: pkg/analyzer/lib/task/model.dart

Issue 1133513003: Cache flushing implementation for the task model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 5 years, 7 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
« no previous file with comments | « pkg/analyzer/lib/task/dart.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/task/model.dart
diff --git a/pkg/analyzer/lib/task/model.dart b/pkg/analyzer/lib/task/model.dart
index a648ced3432acf9965606eef25747b4da52a705b..0e1b8e65d672dd106b571fcb3004666ce19a8f74 100644
--- a/pkg/analyzer/lib/task/model.dart
+++ b/pkg/analyzer/lib/task/model.dart
@@ -279,7 +279,8 @@ abstract class ListResultDescriptor<E> implements ResultDescriptor<List<E>> {
* composite result is specified, then this result will contribute to it.
*/
factory ListResultDescriptor(String name, List<E> defaultValue,
- {CompositeResultDescriptor<List<E>> contributesTo}) = ListResultDescriptorImpl<E>;
+ {CompositeResultDescriptor<List<E>> contributesTo,
+ ResultCachingPolicy<List<E>> cachingPolicy}) = ListResultDescriptorImpl<E>;
@override
ListTaskInput<E> of(AnalysisTarget target);
@@ -338,6 +339,32 @@ abstract class MapTaskInput<K, V> extends TaskInput<Map<K, V>> {
}
/**
+ * A policy object that can compute sizes of results and provide the maximum
+ * active and idle sizes that can be kept in the cache.
+ *
+ * All the [ResultDescriptor]s with the same [ResultCachingPolicy] instance
+ * share the same total size in a cache.
+ */
+abstract class ResultCachingPolicy<T> {
+ /**
+ * Return the maximum total size of results that can be kept in the cache
+ * while analysis is in progress.
+ */
+ int get maxActiveSize;
+
+ /**
+ * Return the maximum total size of results that can be kept in the cache
+ * while analysis is idle.
+ */
+ int get maxIdleSize;
+
+ /**
+ * Return the size of the given [object].
+ */
+ int measure(T object);
+}
+
+/**
* A description of an analysis result that can be computed by an [AnalysisTask].
*
* Clients are not expected to subtype this class.
@@ -346,9 +373,19 @@ abstract class ResultDescriptor<V> {
/**
* Initialize a newly created analysis result to have the given [name]. If a
* composite result is specified, then this result will contribute to it.
+ *
+ * The given [cachingPolicy] is used to limit the total size of results
+ * described by this descriptor. If no policy is specified, the results are
+ * never evicted from the cache, and removed only when they are invalidated.
*/
factory ResultDescriptor(String name, V defaultValue,
- {CompositeResultDescriptor<V> contributesTo}) = ResultDescriptorImpl;
+ {CompositeResultDescriptor<V> contributesTo,
+ ResultCachingPolicy<V> cachingPolicy}) = ResultDescriptorImpl;
+
+ /**
+ * Return the caching policy for results described by this descriptor.
+ */
+ ResultCachingPolicy<V> get cachingPolicy;
/**
* Return the default value for results described by this descriptor.
« no previous file with comments | « pkg/analyzer/lib/task/dart.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698