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 import "dart:collection" show HashMap; | 5 import "dart:collection" show HashMap; |
6 import "dart:_internal"; | 6 import "dart:_internal"; |
7 | 7 |
8 @patch class ReceivePort { | 8 @patch class ReceivePort { |
9 @patch factory ReceivePort() = _ReceivePortImpl; | 9 @patch factory ReceivePort() = _ReceivePortImpl; |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 close() { | 71 close() { |
72 _rawPort.close(); | 72 _rawPort.close(); |
73 _controller.close(); | 73 _controller.close(); |
74 } | 74 } |
75 | 75 |
76 final RawReceivePort _rawPort; | 76 final RawReceivePort _rawPort; |
77 StreamController _controller; | 77 StreamController _controller; |
78 } | 78 } |
79 | 79 |
80 typedef void ImmediateCallback(); | 80 typedef void _ImmediateCallback(); |
81 | 81 |
82 /// The callback that has been registered through `scheduleImmediate`. | 82 /// The callback that has been registered through `scheduleImmediate`. |
83 ImmediateCallback _pendingImmediateCallback; | 83 _ImmediateCallback _pendingImmediateCallback; |
84 | 84 |
85 /// The closure that should be used as scheduleImmediateClosure, when the VM | 85 /// The closure that should be used as scheduleImmediateClosure, when the VM |
86 /// is responsible for the event loop. | 86 /// is responsible for the event loop. |
87 void _isolateScheduleImmediate(void callback()) { | 87 void _isolateScheduleImmediate(void callback()) { |
88 assert(_pendingImmediateCallback == null); | 88 assert(_pendingImmediateCallback == null); |
89 _pendingImmediateCallback = callback; | 89 _pendingImmediateCallback = callback; |
90 } | 90 } |
91 | 91 |
92 void _runPendingImmediateCallback() { | 92 void _runPendingImmediateCallback() { |
93 if (_pendingImmediateCallback != null) { | 93 if (_pendingImmediateCallback != null) { |
94 var callback = _pendingImmediateCallback; | 94 var callback = _pendingImmediateCallback; |
95 _pendingImmediateCallback = null; | 95 _pendingImmediateCallback = null; |
96 callback(); | 96 callback(); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 ImmediateCallback _removePendingImmediateCallback() { | 100 _ImmediateCallback _removePendingImmediateCallback() { |
101 var callback = _pendingImmediateCallback; | 101 var callback = _pendingImmediateCallback; |
102 _pendingImmediateCallback = null; | 102 _pendingImmediateCallback = null; |
103 return callback; | 103 return callback; |
104 } | 104 } |
105 | 105 |
106 /// The embedder can execute this function to get hold of | 106 /// The embedder can execute this function to get hold of |
107 /// [_isolateScheduleImmediate] above. | 107 /// [_isolateScheduleImmediate] above. |
108 Function _getIsolateScheduleImmediateClosure() { | 108 Function _getIsolateScheduleImmediateClosure() { |
109 return _isolateScheduleImmediate; | 109 return _isolateScheduleImmediate; |
110 } | 110 } |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 try { | 578 try { |
579 return Uri.parse(_getCurrentRootUriStr()); | 579 return Uri.parse(_getCurrentRootUriStr()); |
580 } catch (e, s) { | 580 } catch (e, s) { |
581 return null; | 581 return null; |
582 } | 582 } |
583 } | 583 } |
584 | 584 |
585 static String _getCurrentRootUriStr() | 585 static String _getCurrentRootUriStr() |
586 native "Isolate_getCurrentRootUriStr"; | 586 native "Isolate_getCurrentRootUriStr"; |
587 } | 587 } |
OLD | NEW |