<commit_before>// Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.


class _SocketBase {
  // Bit flags used when communicating between the eventhandler and
  // dart code. The EVENT flags are used to indicate events of
  // interest when sending a message from dart code to the
  // eventhandler. When receiving a message from the eventhandler the
  // EVENT flags indicate the events that actually happened. The
  // COMMAND flags are used to send commands from dart to the
  // eventhandler. COMMAND flags are never received from the
  // eventhandler. Additional flags are used to communicate other
  // information.
  static final int _IN_EVENT = 0;
  static final int _OUT_EVENT = 1;
  static final int _ERROR_EVENT = 2;
  static final int _CLOSE_EVENT = 3;

  static final int _CLOSE_COMMAND = 8;
  static final int _SHUTDOWN_READ_COMMAND = 9;
  static final int _SHUTDOWN_WRITE_COMMAND = 10;

  // Flag send to the eventhandler saying that the file descriptor in
  // question represents a listening socket.
  static final int _LISTENING_SOCKET = 16;

  static final int _FIRST_EVENT = _IN_EVENT;
  static final int _LAST_EVENT = _CLOSE_EVENT;

  static final int _FIRST_COMMAND = _CLOSE_COMMAND;
  static final int _LAST_COMMAND = _SHUTDOWN_WRITE_COMMAND;

  _SocketBase () {
    _handler = new ReceivePort();
    _handlerMap = new List(_LAST_EVENT + 1);
    _handlerMask = 0;
    _canActivateHandlers = true;
    _id = -1;
    _handler.receive((var message, ignored) {
      _multiplex(message);
    });
    EventHandler._start();
  }

  /*
   * Multiplexes socket events to the right socket handler.
   */
  void _multiplex(List<int> message) {
    assert(message.length == 1);
    _canActivateHandlers = false;
    int event_mask = message[0];
    for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) {
      if (((event_mask & (1 << i)) != 0)) {
        if ((i == _CLOSE_EVENT) && this is _Socket && _id >= 0) {<commit_msg>Set closed for read state on a socket when indicated by the system<commit_after>// Copyright (c) 2011, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.


class _SocketBase {
  // Bit flags used when communicating between the eventhandler and
  // dart code. The EVENT flags are used to indicate events of
  // interest when sending a message from dart code to the
  // eventhandler. When receiving a message from the eventhandler the
  // EVENT flags indicate the events that actually happened. The
  // COMMAND flags are used to send commands from dart to the
  // eventhandler. COMMAND flags are never received from the
  // eventhandler. Additional flags are used to communicate other
  // information.
  static final int _IN_EVENT = 0;
  static final int _OUT_EVENT = 1;
  static final int _ERROR_EVENT = 2;
  static final int _CLOSE_EVENT = 3;

  static final int _CLOSE_COMMAND = 8;
  static final int _SHUTDOWN_READ_COMMAND = 9;
  static final int _SHUTDOWN_WRITE_COMMAND = 10;

  // Flag send to the eventhandler saying that the file descriptor in
  // question represents a listening socket.
  static final int _LISTENING_SOCKET = 16;

  static final int _FIRST_EVENT = _IN_EVENT;
  static final int _LAST_EVENT = _CLOSE_EVENT;

  static final int _FIRST_COMMAND = _CLOSE_COMMAND;
  static final int _LAST_COMMAND = _SHUTDOWN_WRITE_COMMAND;

  _SocketBase () {
    _handler = new ReceivePort();
    _handlerMap = new List(_LAST_EVENT + 1);
    _handlerMask = 0;
    _canActivateHandlers = true;
    _id = -1;
    _handler.receive((var message, ignored) {
      _multiplex(message);
    });
    EventHandler._start();
  }

  /*
   * Multiplexes socket events to the right socket handler.
   */
  void _multiplex(List<int> message) {
    assert(message.length == 1);
    _canActivateHandlers = false;
    int event_mask = message[0];
    for (int i = _FIRST_EVENT; i <= _LAST_EVENT; i++) {
      if (((event_mask & (1 << i)) != 0)) {
        if ((i == _CLOSE_EVENT) && this is _Socket && _id >= 0) {
          _closedRead = true;
{'fraction_non_alphanumeric': 0.07855973813420622, 'fraction_numerical': 0.010287584755669862, 'mean_word_length': 3.278, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7221345', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1238, 'n_words': 510}