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

Side by Side Diff: corelib/src/isolate.dart

Issue 8505008: Edit documentation for ReceivePort and Isolate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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
« no previous file with comments | « no previous file | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Dart core library. 5 // Dart core library.
6 6
7 /** 7 /**
8 * [SendPort]s are created from [ReceivePort]s. Any message sent through 8 * [SendPort]s are created from [ReceivePort]s. Any message sent through
9 * a [SendPort] is delivered to its respective [ReceivePort]. There might be 9 * a [SendPort] is delivered to its respective [ReceivePort]. There might be
10 * many [SendPort]s for the same [ReceivePort]. 10 * many [SendPort]s for the same [ReceivePort].
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ReceivePort.singleShot(); 71 ReceivePort.singleShot();
72 72
73 /** 73 /**
74 * Sets up a callback function for receiving pending or future 74 * Sets up a callback function for receiving pending or future
75 * messages on this receive port. 75 * messages on this receive port.
76 */ 76 */
77 void receive(void callback(var message, SendPort replyTo)); 77 void receive(void callback(var message, SendPort replyTo));
78 78
79 /** 79 /**
80 * Closes this receive port immediately. Pending messages will not 80 * Closes this receive port immediately. Pending messages will not
81 * be processed and it is impossible to re-open the port. Reply 81 * be processed and it is impossible to re-open the port. Single-shot
82 * ports possibly created through [SendPort.call] are automatically 82 * reply ports, such as those created through [SendPort.call], are
83 * closed when the reply has been received. Multiple invocations of 83 * automatically closed when the reply has been received. Multiple
84 * [close] are allowed but ignored. 84 * invocations of [close] are allowed but ignored.
85 */ 85 */
86 void close(); 86 void close();
87 87
88 /** 88 /**
89 * Converts this receive port to a send port. It is legal to create several 89 * Creates a new send port that sends to this receive port. It is legal to
90 * [SendPort]s from the same [ReceivePort]. 90 * create several [SendPort]s from the same [ReceivePort].
91 */ 91 */
92 SendPort toSendPort(); 92 SendPort toSendPort();
93 93
94 } 94 }
95 95
96 /** 96 /**
97 * The [Isolate] class serves two purposes: (1) as template for spawning a new 97 * The [Isolate] class serves two purposes: (1) as template for spawning a new
98 * isolate, and (2) as entry-point for the newly spawned isolate. 98 * isolate, and (2) as entry-point for the newly spawned isolate.
99 * 99 *
100 * New isolates are spawned by sub-classing [Isolate] and then invoking 100 * New isolates are spawned by sub-classing [Isolate] and then invoking
(...skipping 27 matching lines...) Expand all
128 Isolate.heavy() : _isLight = false; 128 Isolate.heavy() : _isLight = false;
129 129
130 /** 130 /**
131 * Spawns a new isolate, using this instance as template. 131 * Spawns a new isolate, using this instance as template.
132 * 132 *
133 * The new isolate lives in a new thread (for heavy templates) 133 * The new isolate lives in a new thread (for heavy templates)
134 * or in the same thread as the current isolate (for light templates), if 134 * or in the same thread as the current isolate (for light templates), if
135 * possible. 135 * possible.
136 * 136 *
137 * During the initialization of the new isolate a [ReceivePort] is created 137 * During the initialization of the new isolate a [ReceivePort] is created
138 * inside the new isolate and stored in [port]. A corresponding 138 * inside the new isolate and stored in the read-only field [port].
139 * [SendPort] is sent to the isolate that invoked [spawn]. Since spawning an 139 * A corresponding [SendPort] is sent to the isolate that invoked [spawn].
140 * isolate is an asynchronous operation this method returns a [Future] of 140 * Since spawning an isolate is an asynchronous operation this method returns
141 * this [SendPort]. 141 * a [Future] of this [SendPort].
142 * 142 *
143 * A common pattern to instantiate new isolates is to enqueue the instructions 143 * A common pattern to instantiate new isolates is to enqueue the instructions
144 * in [Future.then]. 144 * using [Future.then].
145 * [:myIsolate.spawn().then((SendPort port) { port.send('hi there'); });:] 145 * [:myIsolate.spawn().then((SendPort port) { port.send('hi there'); });:]
146 */ 146 */
147 Future<SendPort> spawn() { 147 Future<SendPort> spawn() {
148 return IsolateNatives.spawn(this, _isLight); 148 return IsolateNatives.spawn(this, _isLight);
149 } 149 }
150 150
151 // The private run method is invoked with the receive port. Before 151 // The private run method is invoked with the receive port. Before
152 // main is invoked we store the port in a field so it can be 152 // main is invoked we store the port in a field so it can be
153 // accessed from subclasses of Isolate. 153 // accessed from subclasses of Isolate.
154 void _run(ReceivePort port) { 154 void _run(ReceivePort port) {
(...skipping 16 matching lines...) Expand all
171 /** 171 /**
172 * When isolates are created, an instance of the template's class is 172 * When isolates are created, an instance of the template's class is
173 * instantiated in the new isolate. After the [port] has been set up, this 173 * instantiated in the new isolate. After the [port] has been set up, this
174 * [main] method is invoked on the instance. 174 * [main] method is invoked on the instance.
175 */ 175 */
176 abstract void main(); 176 abstract void main();
177 177
178 final bool _isLight; 178 final bool _isLight;
179 ReceivePort _port; 179 ReceivePort _port;
180 } 180 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698