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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/isolate_patch.dart

Issue 771993003: Add Isolate.current getter, returning the current isolate as an Isolate object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test Created 6 years 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 | « sdk/lib/_internal/compiler/js_lib/isolate_helper.dart ('k') | sdk/lib/isolate/isolate.dart » ('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) 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 // Patch file for the dart:isolate library. 5 // Patch file for the dart:isolate library.
6 6
7 import 'dart:_js_helper' show patch; 7 import 'dart:_js_helper' show patch;
8 import 'dart:_isolate_helper' show CapabilityImpl, 8 import 'dart:_isolate_helper' show CapabilityImpl,
9 CloseToken, 9 CloseToken,
10 IsolateNatives, 10 IsolateNatives,
11 JsIsolateSink, 11 JsIsolateSink,
12 ReceivePortImpl, 12 ReceivePortImpl,
13 RawReceivePortImpl; 13 RawReceivePortImpl;
14 14
15 @patch 15 @patch
16 class Isolate { 16 class Isolate {
17 static final _currentIsolateCache = IsolateNatives.currentIsolate;
18
19 // `current` must be a getter, not just a final field,
20 // to match the external declaration.
21 @patch
22 static Isolate get current => _currentIsolateCache;
23
17 @patch 24 @patch
18 static Future<Isolate> spawn(void entryPoint(message), var message, 25 static Future<Isolate> spawn(void entryPoint(message), var message,
19 { bool paused: false }) { 26 { bool paused: false }) {
20 try { 27 try {
21 return IsolateNatives.spawnFunction(entryPoint, message, paused) 28 return IsolateNatives.spawnFunction(entryPoint, message, paused)
22 .then((msg) => new Isolate(msg[1], 29 .then((msg) => new Isolate(msg[1],
23 pauseCapability: msg[2], 30 pauseCapability: msg[2],
24 terminateCapability: msg[3])); 31 terminateCapability: msg[3]));
25 } catch (e, st) { 32 } catch (e, st) {
26 return new Future<Isolate>.error(e, st); 33 return new Future<Isolate>.error(e, st);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 factory RawReceivePort([void handler(event)]) { 151 factory RawReceivePort([void handler(event)]) {
145 return new RawReceivePortImpl(handler); 152 return new RawReceivePortImpl(handler);
146 } 153 }
147 } 154 }
148 155
149 @patch 156 @patch
150 class Capability { 157 class Capability {
151 @patch 158 @patch
152 factory Capability() = CapabilityImpl; 159 factory Capability() = CapabilityImpl;
153 } 160 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/isolate_helper.dart ('k') | sdk/lib/isolate/isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698