OLD | NEW |
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 part of dart.isolate; | 5 part of dart.isolate; |
6 | 6 |
7 /** | 7 /** |
8 * The initial [IsolateStream] available by default for this isolate. This | 8 * The initial [IsolateStream] available by default for this isolate. This |
9 * [IsolateStream] is created automatically and it is commonly used to establish | 9 * [IsolateStream] is created automatically and it is commonly used to establish |
10 * the first communication between isolates (see [streamSpawnFunction] and | 10 * the first communication between isolates (see [streamSpawnFunction] and |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 /** | 121 /** |
122 * [IsolateSink]s represent the feed for [IsolateStream]s. Any message written | 122 * [IsolateSink]s represent the feed for [IsolateStream]s. Any message written |
123 * to [this] is delivered to its respective [IsolateStream]. [IsolateSink]s are | 123 * to [this] is delivered to its respective [IsolateStream]. [IsolateSink]s are |
124 * created by [MessageBox]es. | 124 * created by [MessageBox]es. |
125 * | 125 * |
126 * [IsolateSink]s can be transmitted to other isolates. | 126 * [IsolateSink]s can be transmitted to other isolates. |
127 */ | 127 */ |
128 class IsolateSink extends StreamSink<dynamic> { | 128 class IsolateSink extends EventSink<dynamic> { |
129 bool _isClosed = false; | 129 bool _isClosed = false; |
130 final SendPort _port; | 130 final SendPort _port; |
131 IsolateSink._fromPort(this._port); | 131 IsolateSink._fromPort(this._port); |
132 | 132 |
133 /** | 133 /** |
134 * Sends an asynchronous [message] to the linked [IsolateStream]. The message | 134 * Sends an asynchronous [message] to the linked [IsolateStream]. The message |
135 * is copied to the receiving isolate. | 135 * is copied to the receiving isolate. |
136 * | 136 * |
137 * The content of [message] can be: primitive values (null, num, bool, double, | 137 * The content of [message] can be: primitive values (null, num, bool, double, |
138 * String), instances of [IsolateSink]s, and lists and maps whose elements are | 138 * String), instances of [IsolateSink]s, and lists and maps whose elements are |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 * Creates and spawns an isolate whose code is available at [uri]. Like with | 206 * Creates and spawns an isolate whose code is available at [uri]. Like with |
207 * [streamSpawnFunction], the child isolate will have a default [IsolateStream], | 207 * [streamSpawnFunction], the child isolate will have a default [IsolateStream], |
208 * and a this function returns an [IsolateSink] feeding into it. | 208 * and a this function returns an [IsolateSink] feeding into it. |
209 * | 209 * |
210 * See comments at the top of this library for more details. | 210 * See comments at the top of this library for more details. |
211 */ | 211 */ |
212 IsolateSink streamSpawnUri(String uri) { | 212 IsolateSink streamSpawnUri(String uri) { |
213 SendPort sendPort = spawnUri(uri); | 213 SendPort sendPort = spawnUri(uri); |
214 return new IsolateSink._fromPort(sendPort); | 214 return new IsolateSink._fromPort(sendPort); |
215 } | 215 } |
OLD | NEW |