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

Side by Side Diff: lib/runner.dart

Issue 955053002: adding codereview file, formatting, adding gitignore (Closed) Base URL: https://github.com/dart-lang/isolate.git@master
Patch Set: Created 5 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 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 /** 5 /**
6 * A [Runner] runs a function, potentially in a different scope 6 * A [Runner] runs a function, potentially in a different scope
7 * or even isolate. 7 * or even isolate.
8 */ 8 */
9 library dart.pkg.isolate.runner; 9 library dart.pkg.isolate.runner;
10 10
(...skipping 24 matching lines...) Expand all
35 * If the returned future does not complete before `timeLimit` has passed, 35 * If the returned future does not complete before `timeLimit` has passed,
36 * the [onTimeout] action is executed instead, and its result (whether it 36 * the [onTimeout] action is executed instead, and its result (whether it
37 * returns or throws) is used as the result of the returned future. 37 * returns or throws) is used as the result of the returned future.
38 * 38 *
39 * If `onTimeout` is omitted, a timeout will cause the returned future to 39 * If `onTimeout` is omitted, a timeout will cause the returned future to
40 * complete with a [TimeoutException]. 40 * complete with a [TimeoutException].
41 * 41 *
42 * The default implementation runs the function in the current isolate. 42 * The default implementation runs the function in the current isolate.
43 */ 43 */
44 Future run(function(argument), Object argument, 44 Future run(function(argument), Object argument,
45 {Duration timeout, onTimeout()}) { 45 {Duration timeout, onTimeout()}) {
Lasse Reichstein Nielsen 2015/02/26 10:59:15 Indent as original.
46 Future result = new Future.sync(() => function(argument)); 46 Future result = new Future.sync(() => function(argument));
47 if (timeout != null) { 47 if (timeout != null) {
48 result = result.timeout(timeout, onTimeout: onTimeout); 48 result = result.timeout(timeout, onTimeout: onTimeout);
49 } 49 }
50 return result; 50 return result;
51 } 51 }
52 52
53 /** 53 /**
54 * Stop the runner. 54 * Stop the runner.
55 * 55 *
56 * If the runner has allocated resources, e.g., an isolate, it should 56 * If the runner has allocated resources, e.g., an isolate, it should
57 * be released. No further calls to [run] should be made after calling 57 * be released. No further calls to [run] should be made after calling
58 * stop. 58 * stop.
59 */ 59 */
60 Future close() => new Future.value(); 60 Future close() => new Future.value();
61 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698