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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.task.model; 5 library analyzer.src.task.model;
6 6
7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
8 import 'package:analyzer/src/task/inputs.dart'; 8 import 'package:analyzer/src/task/inputs.dart';
9 import 'package:analyzer/task/model.dart'; 9 import 'package:analyzer/task/model.dart';
10 10
11 /** 11 /**
12 * The default [ResultCachingPolicy], results are never flushed.
13 */
14 const ResultCachingPolicy DEFAULT_CACHING_POLICY =
15 const SimpleResultCachingPolicy(-1, -1);
16
17 /**
12 * A concrete implementation of a [CompositeResultDescriptor]. 18 * A concrete implementation of a [CompositeResultDescriptor].
13 */ 19 */
14 class CompositeResultDescriptorImpl<V> extends ResultDescriptorImpl<V> 20 class CompositeResultDescriptorImpl<V> extends ResultDescriptorImpl<V>
15 implements CompositeResultDescriptor<V> { 21 implements CompositeResultDescriptor<V> {
16 /** 22 /**
17 * The results that contribute to this result. 23 * The results that contribute to this result.
18 */ 24 */
19 final List<ResultDescriptor<V>> contributors = <ResultDescriptor<V>>[]; 25 final List<ResultDescriptor<V>> contributors = <ResultDescriptor<V>>[];
20 26
21 /** 27 /**
(...skipping 13 matching lines...) Expand all
35 * A concrete implementation of a [ListResultDescriptor]. 41 * A concrete implementation of a [ListResultDescriptor].
36 */ 42 */
37 class ListResultDescriptorImpl<E> extends ResultDescriptorImpl<List<E>> 43 class ListResultDescriptorImpl<E> extends ResultDescriptorImpl<List<E>>
38 implements ListResultDescriptor<E> { 44 implements ListResultDescriptor<E> {
39 /** 45 /**
40 * Initialize a newly created analysis result to have the given [name] and 46 * Initialize a newly created analysis result to have the given [name] and
41 * [defaultValue]. If a composite result is specified, then this result will 47 * [defaultValue]. If a composite result is specified, then this result will
42 * contribute to it. 48 * contribute to it.
43 */ 49 */
44 ListResultDescriptorImpl(String name, List<E> defaultValue, 50 ListResultDescriptorImpl(String name, List<E> defaultValue,
45 {CompositeResultDescriptor contributesTo}) 51 {CompositeResultDescriptor contributesTo,
46 : super(name, defaultValue, contributesTo: contributesTo); 52 ResultCachingPolicy<List<E>> cachingPolicy: DEFAULT_CACHING_POLICY})
53 : super(name, defaultValue,
54 contributesTo: contributesTo, cachingPolicy: cachingPolicy);
47 55
48 @override 56 @override
49 ListTaskInput<E> of(AnalysisTarget target) => 57 ListTaskInput<E> of(AnalysisTarget target) =>
50 new ListTaskInputImpl<E>(target, this); 58 new ListTaskInputImpl<E>(target, this);
51 } 59 }
52 60
53 /** 61 /**
54 * A concrete implementation of a [ResultDescriptor]. 62 * A concrete implementation of a [ResultDescriptor].
55 */ 63 */
56 class ResultDescriptorImpl<V> implements ResultDescriptor<V> { 64 class ResultDescriptorImpl<V> implements ResultDescriptor<V> {
57 /** 65 /**
58 * The name of the result, used for debugging. 66 * The name of the result, used for debugging.
59 */ 67 */
60 final String name; 68 final String name;
61 69
62 /** 70 /**
63 * Return the default value for results described by this descriptor. 71 * Return the default value for results described by this descriptor.
64 */ 72 */
65 final V defaultValue; 73 final V defaultValue;
66 74
67 /** 75 /**
76 * The caching policy for results described by this descriptor.
77 */
78 final ResultCachingPolicy<V> cachingPolicy;
79
80 /**
68 * Initialize a newly created analysis result to have the given [name] and 81 * Initialize a newly created analysis result to have the given [name] and
69 * [defaultValue]. If a composite result is specified, then this result will 82 * [defaultValue]. If a composite result is specified, then this result will
70 * contribute to it. 83 * contribute to it.
71 */ 84 */
72 ResultDescriptorImpl(this.name, this.defaultValue, 85 ResultDescriptorImpl(this.name, this.defaultValue,
73 {CompositeResultDescriptor contributesTo}) { 86 {CompositeResultDescriptor contributesTo,
87 this.cachingPolicy: DEFAULT_CACHING_POLICY}) {
74 if (contributesTo is CompositeResultDescriptorImpl) { 88 if (contributesTo is CompositeResultDescriptorImpl) {
75 contributesTo.recordContributor(this); 89 contributesTo.recordContributor(this);
76 } 90 }
77 } 91 }
78 92
79 @override 93 @override
80 TaskInput<V> of(AnalysisTarget target) => 94 TaskInput<V> of(AnalysisTarget target) =>
81 new SimpleTaskInput<V>(target, this); 95 new SimpleTaskInput<V>(target, this);
82 96
83 @override 97 @override
84 String toString() => name; 98 String toString() => name;
85 } 99 }
86 100
87 /** 101 /**
102 * A simple [ResultCachingPolicy] implementation that consider all the objects
103 * to be of the size `1`.
104 */
105 class SimpleResultCachingPolicy<T> implements ResultCachingPolicy<T> {
106 @override
107 final int maxActiveSize;
108
109 @override
110 final int maxIdleSize;
111
112 const SimpleResultCachingPolicy(this.maxActiveSize, this.maxIdleSize);
113
114 @override
115 int measure(T object) => 1;
116 }
117
118 /**
88 * A concrete implementation of a [TaskDescriptor]. 119 * A concrete implementation of a [TaskDescriptor].
89 */ 120 */
90 class TaskDescriptorImpl implements TaskDescriptor { 121 class TaskDescriptorImpl implements TaskDescriptor {
91 /** 122 /**
92 * The name of the described task, used for debugging. 123 * The name of the described task, used for debugging.
93 */ 124 */
94 final String name; 125 final String name;
95 126
96 /** 127 /**
97 * The function used to build the analysis task. 128 * The function used to build the analysis task.
(...skipping 26 matching lines...) Expand all
124 Map<String, dynamic> inputs, Object inputMemento) { 155 Map<String, dynamic> inputs, Object inputMemento) {
125 AnalysisTask task = buildTask(context, target); 156 AnalysisTask task = buildTask(context, target);
126 task.inputs = inputs; 157 task.inputs = inputs;
127 task.inputMemento = inputMemento; 158 task.inputMemento = inputMemento;
128 return task; 159 return task;
129 } 160 }
130 161
131 @override 162 @override
132 String toString() => name; 163 String toString() => name;
133 } 164 }
OLDNEW
« 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