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 // Patch file for the dart:isolate library. | 5 // Patch file for the dart:isolate library. |
6 | 6 |
7 patch ReceivePort get port { | 7 patch ReceivePort get port { |
8 if (lazyPort == null) { | 8 if (lazyPort == null) { |
9 lazyPort = new ReceivePort(); | 9 lazyPort = new ReceivePort(); |
10 } | 10 } |
11 return lazyPort; | 11 return lazyPort; |
12 } | 12 } |
13 | 13 |
14 patch SendPort spawnFunction(void topLevelFunction(), | 14 patch SendPort spawnFunction(void topLevelFunction(), |
15 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]) { | 15 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]) { |
16 return IsolateNatives.spawnFunction(topLevelFunction); | 16 return IsolateNatives.spawnFunction(topLevelFunction); |
17 } | 17 } |
18 | 18 |
19 patch SendPort spawnUri(String uri) { | 19 patch SendPort spawnUri(String uri) { |
20 return IsolateNatives.spawn(null, uri, false); | 20 return IsolateNatives.spawn(null, uri, false); |
21 } | 21 } |
22 | 22 |
23 | 23 |
24 /** Default factory for receive ports. */ | 24 /** Default factory for receive ports. */ |
25 patch class ReceivePort { | 25 patch class ReceivePort { |
26 patch factory ReceivePort() { | 26 patch factory ReceivePort() { |
27 return new ReceivePortImpl(); | 27 return new ReceivePortImpl(); |
28 } | 28 } |
29 } | 29 } |
30 | |
31 patch class Timer { | |
32 patch factory Timer(int milliseconds, void callback(Timer timer)) { | |
33 if (!hasTimer()) { | |
34 throw new UnsupportedError("Timer interface not supported."); | |
35 } | |
36 return new TimerImpl(milliseconds, callback); | |
37 } | |
38 | |
39 /** | |
40 * Creates a new repeating timer. The [callback] is invoked every | |
41 * [milliseconds] millisecond until cancelled. | |
42 */ | |
43 patch factory Timer.repeating(int milliseconds, void callback(Timer timer)) { | |
44 if (!hasTimer()) { | |
45 throw new UnsupportedError("Timer interface not supported."); | |
46 } | |
47 return new TimerImpl.repeating(milliseconds, callback); | |
48 } | |
49 } | |
OLD | NEW |