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

Side by Side Diff: lib/isolate_runner.dart

Issue 1083653002: Update package:isolate to make kill priority named. (Closed) Base URL: https://github.com/dart-lang/isolate.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | pubspec.yaml » ('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 isolate.isolate_runner; 5 library isolate.isolate_runner;
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:isolate"; 8 import "dart:isolate";
9 9
10 import 'ports.dart'; 10 import 'ports.dart';
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 /// If the isolate is already dead, the returned future will not complete. 94 /// If the isolate is already dead, the returned future will not complete.
95 /// If that may be the case, use [Future.timeout] on the returned future 95 /// If that may be the case, use [Future.timeout] on the returned future
96 /// to take extra action after a while. Example: 96 /// to take extra action after a while. Example:
97 /// 97 ///
98 /// var f = isolate.kill(); 98 /// var f = isolate.kill();
99 /// f.then((_) => print('Dead') 99 /// f.then((_) => print('Dead')
100 /// .timeout(new Duration(...), onTimeout: () => print('No response')); 100 /// .timeout(new Duration(...), onTimeout: () => print('No response'));
101 Future kill({Duration timeout: const Duration(seconds: 1)}) { 101 Future kill({Duration timeout: const Duration(seconds: 1)}) {
102 Future onExit = singleResponseFuture(isolate.addOnExitListener); 102 Future onExit = singleResponseFuture(isolate.addOnExitListener);
103 if (Duration.ZERO == timeout) { 103 if (Duration.ZERO == timeout) {
104 isolate.kill(Isolate.IMMEDIATE); 104 isolate.kill(priority: Isolate.IMMEDIATE);
105 return onExit; 105 return onExit;
106 } else { 106 } else {
107 // Try a more gentle shutdown sequence. 107 // Try a more gentle shutdown sequence.
108 _commandPort.send(list1(_SHUTDOWN)); 108 _commandPort.send(list1(_SHUTDOWN));
109 return onExit.timeout(timeout, onTimeout: () { 109 return onExit.timeout(timeout, onTimeout: () {
110 isolate.kill(Isolate.IMMEDIATE); 110 isolate.kill(priority: Isolate.IMMEDIATE);
111 return onExit; 111 return onExit;
112 }); 112 });
113 } 113 }
114 } 114 }
115 115
116 /// Queries the isolate on whether it's alive. 116 /// Queries the isolate on whether it's alive.
117 /// 117 ///
118 /// If the isolate is alive and responding to commands, the 118 /// If the isolate is alive and responding to commands, the
119 /// returned future completes with `true`. 119 /// returned future completes with `true`.
120 /// 120 ///
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 case _RUN: 288 case _RUN:
289 Function function = command[1]; 289 Function function = command[1];
290 var argument = command[2]; 290 var argument = command[2];
291 SendPort responsePort = command[3]; 291 SendPort responsePort = command[3];
292 sendFutureResult(new Future.sync(() => function(argument)), 292 sendFutureResult(new Future.sync(() => function(argument)),
293 responsePort); 293 responsePort);
294 return; 294 return;
295 } 295 }
296 } 296 }
297 } 297 }
OLDNEW
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698