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

Side by Side Diff: pkg/dartino_compiler/lib/src/hub/session_manager.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 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
OLDNEW
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fletchc.hub.session_manager; 5 library dartino_compiler.hub.session_manager;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future, 8 Future,
9 Timer; 9 Timer;
10 10
11 import 'client_commands.dart' show 11 import 'client_commands.dart' show
12 CommandSender; 12 CommandSender;
13 13
14 import 'hub_main.dart' show 14 import 'hub_main.dart' show
15 WorkerConnection; 15 WorkerConnection;
16 16
17 export 'hub_main.dart' show 17 export 'hub_main.dart' show
18 WorkerConnection; 18 WorkerConnection;
19 19
20 import '../worker/developer.dart' show 20 import '../worker/developer.dart' show
21 Settings; 21 Settings;
22 22
23 import '../diagnostic.dart' show 23 import '../diagnostic.dart' show
24 DiagnosticKind, 24 DiagnosticKind,
25 DiagnosticParameter, 25 DiagnosticParameter,
26 InputError, 26 InputError,
27 throwFatalError, 27 throwFatalError,
28 throwInternalError; 28 throwInternalError;
29 29
30 import '../../fletch_system.dart' show 30 import '../../dartino_system.dart' show
31 FletchDelta; 31 DartinoDelta;
32 32
33 export '../../fletch_system.dart' show 33 export '../../dartino_system.dart' show
34 FletchDelta; 34 DartinoDelta;
35 35
36 import '../../vm_session.dart' show 36 import '../../vm_session.dart' show
37 Session; 37 Session;
38 38
39 export '../../vm_session.dart' show 39 export '../../vm_session.dart' show
40 Session; 40 Session;
41 41
42 import '../../fletch_compiler.dart' show 42 import '../../dartino_compiler.dart' show
43 FletchCompiler; 43 DartinoCompiler;
44 44
45 export '../../fletch_compiler.dart' show 45 export '../../dartino_compiler.dart' show
46 FletchCompiler; 46 DartinoCompiler;
47 47
48 import '../../incremental/fletchc_incremental.dart' show 48 import '../../incremental/dartino_compiler_incremental.dart' show
49 IncrementalCompiler; 49 IncrementalCompiler;
50 50
51 export '../../incremental/fletchc_incremental.dart' show 51 export '../../incremental/dartino_compiler_incremental.dart' show
52 IncrementalCompiler; 52 IncrementalCompiler;
53 53
54 import '../../fletch_vm.dart' show 54 import '../../dartino_vm.dart' show
55 FletchVm; 55 DartinoVm;
56 56
57 export '../../fletch_vm.dart' show 57 export '../../dartino_vm.dart' show
58 FletchVm; 58 DartinoVm;
59 59
60 // TODO(karlklose): we need a better API for session management. 60 // TODO(karlklose): we need a better API for session management.
61 class Sessions { 61 class Sessions {
62 static Iterable<String> get names { 62 static Iterable<String> get names {
63 return internalSessions.keys; 63 return internalSessions.keys;
64 } 64 }
65 } 65 }
66 66
67 final Map<String, UserSession> internalSessions = <String, UserSession>{}; 67 final Map<String, UserSession> internalSessions = <String, UserSession>{};
68 68
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 /// The state stored in a worker isolate of a [UserSession]. 164 /// The state stored in a worker isolate of a [UserSession].
165 /// TODO(wibling): This should be moved into a worker specific file. 165 /// TODO(wibling): This should be moved into a worker specific file.
166 class SessionState { 166 class SessionState {
167 final String name; 167 final String name;
168 168
169 final BufferingOutputSink stdoutSink = new BufferingOutputSink(); 169 final BufferingOutputSink stdoutSink = new BufferingOutputSink();
170 170
171 final BufferingOutputSink stderrSink = new BufferingOutputSink(); 171 final BufferingOutputSink stderrSink = new BufferingOutputSink();
172 172
173 final FletchCompiler compilerHelper; 173 final DartinoCompiler compilerHelper;
174 174
175 final IncrementalCompiler compiler; 175 final IncrementalCompiler compiler;
176 176
177 final List<FletchDelta> compilationResults = <FletchDelta>[]; 177 final List<DartinoDelta> compilationResults = <DartinoDelta>[];
178 178
179 final List<String> loggedMessages = <String>[]; 179 final List<String> loggedMessages = <String>[];
180 180
181 Uri script; 181 Uri script;
182 182
183 Session session; 183 Session session;
184 184
185 FletchVm fletchVm; 185 DartinoVm dartinoVm;
186 186
187 int fletchAgentVmId; 187 int dartinoAgentVmId;
188 188
189 Settings settings; 189 Settings settings;
190 190
191 bool explicitAttach = false; 191 bool explicitAttach = false;
192 192
193 SessionState(this.name, this.compilerHelper, this.compiler, this.settings); 193 SessionState(this.name, this.compilerHelper, this.compiler, this.settings);
194 194
195 bool get hasRemoteVm => fletchAgentVmId != null; 195 bool get hasRemoteVm => dartinoAgentVmId != null;
196 196
197 bool get colorsDisabled => session == null ? false : session.colorsDisabled; 197 bool get colorsDisabled => session == null ? false : session.colorsDisabled;
198 198
199 void addCompilationResult(FletchDelta delta) { 199 void addCompilationResult(DartinoDelta delta) {
200 compilationResults.add(delta); 200 compilationResults.add(delta);
201 } 201 }
202 202
203 void resetCompiler() { 203 void resetCompiler() {
204 compilationResults.clear(); 204 compilationResults.clear();
205 } 205 }
206 206
207 Future terminateSession() async { 207 Future terminateSession() async {
208 if (session != null) { 208 if (session != null) {
209 if (!session.terminated) { 209 if (!session.terminated) {
210 bool done = false; 210 bool done = false;
211 Timer timer = new Timer(const Duration(seconds: 5), () { 211 Timer timer = new Timer(const Duration(seconds: 5), () {
212 if (!done) { 212 if (!done) {
213 print("Timed out waiting for Fletch VM to shutdown; killing " 213 print("Timed out waiting for Dartino VM to shutdown; killing "
214 "session"); 214 "session");
215 session.kill(); 215 session.kill();
216 } 216 }
217 }); 217 });
218 await session.terminateSession(); 218 await session.terminateSession();
219 done = true; 219 done = true;
220 timer.cancel(); 220 timer.cancel();
221 } 221 }
222 explicitAttach = false; 222 explicitAttach = false;
223 } 223 }
(...skipping 23 matching lines...) Expand all
247 /// otherwise API that takes a [SessionState] object doesn't work correctly 247 /// otherwise API that takes a [SessionState] object doesn't work correctly
248 /// and testing becomes hard. 248 /// and testing becomes hard.
249 /// 249 ///
250 /// TODO(ahe): Perhaps we can remove this getter, and [internalCurrent] by 250 /// TODO(ahe): Perhaps we can remove this getter, and [internalCurrent] by
251 /// storing this object in ../worker/worker_main.dart. For example, 251 /// storing this object in ../worker/worker_main.dart. For example,
252 /// [workerMain] holds a reference to an instance of [SessionState] and 252 /// [workerMain] holds a reference to an instance of [SessionState] and
253 /// passes this reference to [WorkerSideTask] which can in turn pass it on to 253 /// passes this reference to [WorkerSideTask] which can in turn pass it on to
254 /// the verb/task in [WorkerSideTask.performTask]. 254 /// the verb/task in [WorkerSideTask.performTask].
255 static SessionState get current => internalCurrent; 255 static SessionState get current => internalCurrent;
256 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698