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