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

Unified Diff: pkg/analyzer/lib/src/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/src/task/dart.dart ('k') | pkg/analyzer/lib/task/dart.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/model.dart
diff --git a/pkg/analyzer/lib/src/task/model.dart b/pkg/analyzer/lib/src/task/model.dart
index b8671bc98f89bcb44653b9012ec1ff9581bf7b7e..23c44537dadb26b45a09d6ee8ef382b98eb05c5d 100644
--- a/pkg/analyzer/lib/src/task/model.dart
+++ b/pkg/analyzer/lib/src/task/model.dart
@@ -9,6 +9,12 @@ import 'package:analyzer/src/task/inputs.dart';
import 'package:analyzer/task/model.dart';
/**
+ * The default [ResultCachingPolicy], results are never flushed.
+ */
+const ResultCachingPolicy DEFAULT_CACHING_POLICY =
+ const SimpleResultCachingPolicy(-1, -1);
+
+/**
* A concrete implementation of a [CompositeResultDescriptor].
*/
class CompositeResultDescriptorImpl<V> extends ResultDescriptorImpl<V>
@@ -42,8 +48,10 @@ class ListResultDescriptorImpl<E> extends ResultDescriptorImpl<List<E>>
* contribute to it.
*/
ListResultDescriptorImpl(String name, List<E> defaultValue,
- {CompositeResultDescriptor contributesTo})
- : super(name, defaultValue, contributesTo: contributesTo);
+ {CompositeResultDescriptor contributesTo,
+ ResultCachingPolicy<List<E>> cachingPolicy: DEFAULT_CACHING_POLICY})
+ : super(name, defaultValue,
+ contributesTo: contributesTo, cachingPolicy: cachingPolicy);
@override
ListTaskInput<E> of(AnalysisTarget target) =>
@@ -65,12 +73,18 @@ class ResultDescriptorImpl<V> implements ResultDescriptor<V> {
final V defaultValue;
/**
+ * The caching policy for results described by this descriptor.
+ */
+ final ResultCachingPolicy<V> cachingPolicy;
+
+ /**
* Initialize a newly created analysis result to have the given [name] and
* [defaultValue]. If a composite result is specified, then this result will
* contribute to it.
*/
ResultDescriptorImpl(this.name, this.defaultValue,
- {CompositeResultDescriptor contributesTo}) {
+ {CompositeResultDescriptor contributesTo,
+ this.cachingPolicy: DEFAULT_CACHING_POLICY}) {
if (contributesTo is CompositeResultDescriptorImpl) {
contributesTo.recordContributor(this);
}
@@ -85,6 +99,23 @@ class ResultDescriptorImpl<V> implements ResultDescriptor<V> {
}
/**
+ * A simple [ResultCachingPolicy] implementation that consider all the objects
+ * to be of the size `1`.
+ */
+class SimpleResultCachingPolicy<T> implements ResultCachingPolicy<T> {
+ @override
+ final int maxActiveSize;
+
+ @override
+ final int maxIdleSize;
+
+ const SimpleResultCachingPolicy(this.maxActiveSize, this.maxIdleSize);
+
+ @override
+ int measure(T object) => 1;
+}
+
+/**
* A concrete implementation of a [TaskDescriptor].
*/
class TaskDescriptorImpl implements TaskDescriptor {
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/lib/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698