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 | 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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 _SocketBase () { | 36 _SocketBase () { |
37 _handlerMap = new List(_LAST_EVENT + 1); | 37 _handlerMap = new List(_LAST_EVENT + 1); |
38 _handlerMask = 0; | 38 _handlerMask = 0; |
39 _canActivateHandlers = true; | 39 _canActivateHandlers = true; |
40 _id = -1; | 40 _id = -1; |
41 _EventHandler._start(); | 41 _EventHandler._start(); |
42 } | 42 } |
43 | 43 |
44 // Multiplexes socket events to the socket handlers. | 44 // Multiplexes socket events to the socket handlers. |
45 void _multiplex(List<int> message) { | 45 void _multiplex(int event_mask) { |
46 assert(message.length == 1); | |
47 _canActivateHandlers = false; | 46 _canActivateHandlers = false; |
48 int event_mask = message[0]; | |
49 for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) { | 47 for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) { |
50 if (((event_mask & (1 << i)) != 0)) { | 48 if (((event_mask & (1 << i)) != 0)) { |
51 if ((i == _CLOSE_EVENT) && this is _Socket && _id >= 0) { | 49 if ((i == _CLOSE_EVENT) && this is _Socket && _id >= 0) { |
52 _closedRead = true; | 50 _closedRead = true; |
53 if (_closedWrite) _close(); | 51 if (_closedWrite) _close(); |
54 } | 52 } |
55 | 53 |
56 var eventHandler = _handlerMap[i]; | 54 var eventHandler = _handlerMap[i]; |
57 if (eventHandler != null) { | 55 if (eventHandler != null) { |
58 // Unregister the out handler before executing it. | 56 // Unregister the out handler before executing it. |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 bool _seenFirstOutEvent = false; | 458 bool _seenFirstOutEvent = false; |
461 bool _closedRead = false; | 459 bool _closedRead = false; |
462 bool _closedWrite = false; | 460 bool _closedWrite = false; |
463 bool _pipe = false; | 461 bool _pipe = false; |
464 Function _clientConnectHandler; | 462 Function _clientConnectHandler; |
465 Function _clientWriteHandler; | 463 Function _clientWriteHandler; |
466 SocketInputStream _inputStream; | 464 SocketInputStream _inputStream; |
467 SocketOutputStream _outputStream; | 465 SocketOutputStream _outputStream; |
468 } | 466 } |
469 | 467 |
OLD | NEW |