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

Side by Side Diff: sdk/lib/isolate/base.dart

Issue 11413101: Added support for isolate unhandled exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class IsolateSpawnException implements Exception { 5 class IsolateSpawnException implements Exception {
6 const IsolateSpawnException(String this._s); 6 const IsolateSpawnException(String this._s);
7 String toString() => "IsolateSpawnException: '$_s'"; 7 String toString() => "IsolateSpawnException: '$_s'";
8 final String _s; 8 final String _s;
9 } 9 }
10 10
11 /** 11 /**
12 * The initial [ReceivePort] available by default for this isolate. This 12 * The initial [ReceivePort] available by default for this isolate. This
13 * [ReceivePort] is created automatically and it is commonly used to establish 13 * [ReceivePort] is created automatically and it is commonly used to establish
14 * the first communication between isolates (see [spawnFunction] and 14 * the first communication between isolates (see [spawnFunction] and
15 * [spawnUri]). 15 * [spawnUri]).
16 */ 16 */
17 external ReceivePort get port; 17 external ReceivePort get port;
18 18
19 /** 19 /**
20 * Creates and spawns an isolate that shares the same code as the current 20 * Creates and spawns an isolate that shares the same code as the current
21 * isolate, but that starts from [topLevelFunction]. The [topLevelFunction] 21 * isolate, but that starts from [topLevelFunction]. The [topLevelFunction]
22 * argument must be a static top-level function or a static method that takes no 22 * argument must be a static top-level function or a static method that takes no
23 * arguments. It is illegal to pass a function closure. 23 * arguments. It is illegal to pass a function closure.
siva 2012/11/21 00:45:04 We probably need some documentation here for the u
Tom Ball 2012/11/21 05:22:38 Done.
24 * 24 *
25 * When any isolate starts (even the main script of the application), a default 25 * When any isolate starts (even the main script of the application), a default
26 * [ReceivePort] is created for it. This port is available from the top-level 26 * [ReceivePort] is created for it. This port is available from the top-level
27 * getter [port] defined in this library. 27 * getter [port] defined in this library.
28 * 28 *
29 * [spawnFunction] returns a [SendPort] derived from the child isolate's default 29 * [spawnFunction] returns a [SendPort] derived from the child isolate's default
30 * port. 30 * port.
31 * 31 *
32 * See comments at the top of this library for more details. 32 * See comments at the top of this library for more details.
33 */ 33 */
34 // Note this feature is not yet available in the dartvm. 34 // Note this feature is not yet available in the dartvm.
35 external SendPort spawnFunction(void topLevelFunction()); 35 external SendPort spawnFunction(void topLevelFunction(),
36 36 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]);
37 /** 37 /**
38 * Creates and spawns an isolate whose code is available at [uri]. Like with 38 * Creates and spawns an isolate whose code is available at [uri]. Like with
39 * [spawnFunction], the child isolate will have a default [ReceivePort], and a 39 * [spawnFunction], the child isolate will have a default [ReceivePort], and a
40 * this function returns a [SendPort] derived from it. 40 * this function returns a [SendPort] derived from it.
siva 2012/11/21 00:45:04 Ditto comment regarding documentation of the unhan
Tom Ball 2012/11/21 05:22:38 Done.
41 * 41 *
42 * See comments at the top of this library for more details. 42 * See comments at the top of this library for more details.
43 */ 43 */
44 external SendPort spawnUri(String uri); 44 external SendPort spawnUri(String uri,
45 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]);
45 46
46 /** 47 /**
47 * [SendPort]s are created from [ReceivePort]s. Any message sent through 48 * [SendPort]s are created from [ReceivePort]s. Any message sent through
48 * a [SendPort] is delivered to its respective [ReceivePort]. There might be 49 * a [SendPort] is delivered to its respective [ReceivePort]. There might be
49 * many [SendPort]s for the same [ReceivePort]. 50 * many [SendPort]s for the same [ReceivePort].
50 * 51 *
51 * [SendPort]s can be transmitted to other isolates. 52 * [SendPort]s can be transmitted to other isolates.
52 */ 53 */
53 abstract class SendPort { 54 abstract class SendPort {
54 55
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 SendPort toSendPort(); 136 SendPort toSendPort();
136 137
137 } 138 }
138 139
139 // TODO(kasperl): Document this. 140 // TODO(kasperl): Document this.
140 abstract class SendPortSync { 141 abstract class SendPortSync {
141 142
142 callSync(var message); 143 callSync(var message);
143 144
144 } 145 }
146
147 class _ReceivePortFactory {
148 external factory ReceivePort();
149 }
siva 2012/11/21 00:45:04 What is this change? Is it related to the Unhandle
Tom Ball 2012/11/21 05:22:38 I didn't write this, so I'm guessing it's related
150
151 /**
152 * Wraps unhandled exceptions thrown during isolate execution. It is
153 * used to show both the error message and the stack trace for unhandled
154 * exceptions.
155 */
156 class IsolateUnhandledException implements Exception {
157 /** Message being handled when exception occurred. */
158 final message;
159
160 /** Wrapped exception. */
161 final source;
162
163 /** Trace for the wrapped exception. */
164 final Object stackTrace;
165
166 const IsolateUnhandledException(this.message, this.source, this.stackTrace);
167
168 String toString() {
169 return 'IsolateUnhandledException: exception while handling message: '
170 '${message} \n '
171 '${source.toString().replaceAll("\n", "\n ")}\n'
172 'original stack trace:\n '
173 '${stackTrace.toString().replaceAll("\n","\n ")}';
174 }
175 }
176
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698