| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 5 |
| 6 class _SocketBase { | 6 class _SocketBase { |
| 7 // Bit flags used when communicating between the eventhandler and | 7 // Bit flags used when communicating between the eventhandler and |
| 8 // dart code. The EVENT flags are used to indicate events of | 8 // dart code. The EVENT flags are used to indicate events of |
| 9 // interest when sending a message from dart code to the | 9 // interest when sending a message from dart code to the |
| 10 // eventhandler. When receiving a message from the eventhandler the | 10 // eventhandler. When receiving a message from the eventhandler the |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 /* | 47 /* |
| 48 * Multiplexes socket events to the right socket handler. | 48 * Multiplexes socket events to the right socket handler. |
| 49 */ | 49 */ |
| 50 void _multiplex(List<int> message) { | 50 void _multiplex(List<int> message) { |
| 51 assert(message.length == 1); | 51 assert(message.length == 1); |
| 52 _canActivateHandlers = false; | 52 _canActivateHandlers = false; |
| 53 int event_mask = message[0]; | 53 int event_mask = message[0]; |
| 54 for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) { | 54 for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) { |
| 55 if (((event_mask & (1 << i)) != 0)) { | 55 if (((event_mask & (1 << i)) != 0)) { |
| 56 if ((i == _CLOSE_EVENT) && this is _Socket && _id >= 0) { | 56 if ((i == _CLOSE_EVENT) && this is _Socket && _id >= 0) { |
| 57 _closedRead = true; |
| 57 if (_closedWrite) _close(); | 58 if (_closedWrite) _close(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 var eventHandler = _handlerMap[i]; | 61 var eventHandler = _handlerMap[i]; |
| 61 if (eventHandler != null) { | 62 if (eventHandler != null) { |
| 62 // Unregister the out handler before executing it. | 63 // Unregister the out handler before executing it. |
| 63 if (i == _OUT_EVENT) _setHandler(i, null); | 64 if (i == _OUT_EVENT) _setHandler(i, null); |
| 64 | 65 |
| 65 // Don't call the in handler if there is no data available | 66 // Don't call the in handler if there is no data available |
| 66 // after all. | 67 // after all. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 350 } |
| 350 return _outputStream; | 351 return _outputStream; |
| 351 } | 352 } |
| 352 | 353 |
| 353 bool _closedRead = false; | 354 bool _closedRead = false; |
| 354 bool _closedWrite = false; | 355 bool _closedWrite = false; |
| 355 SocketInputStream _inputStream; | 356 SocketInputStream _inputStream; |
| 356 SocketOutputStream _outputStream; | 357 SocketOutputStream _outputStream; |
| 357 } | 358 } |
| 358 | 359 |
| OLD | NEW |