<commit_before>/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2015. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

#include "Dispatcher.h"

#include <algorithm>
#include <iterator>

#include "tcpsockets/TCPAcceptor.h"
#include "tcpsockets/TCPConnector.h"
#include "Log.h"

using namespace nt;

ATOMIC_STATIC_INIT(Dispatcher)

void Dispatcher::StartServer(StringRef persist_filename,
                             const char* listen_address, unsigned int port) {
  DispatcherBase::StartServer(persist_filename,
                              std::unique_ptr<NetworkAcceptor>(new TCPAcceptor(
                                  static_cast<int>(port), listen_address)));
}

void Dispatcher::StartClient(const char* server_name, unsigned int port) {
  DispatcherBase::StartClient(std::bind(&TCPConnector::connect, server_name,
                                        static_cast<int>(port), 1));
}

Dispatcher::Dispatcher()
    : Dispatcher(Storage::GetInstance(), Notifier::GetInstance()) {}
<commit_msg>StartClient(): Make a local copy of server_name.<commit_after>/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2015. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

#include "Dispatcher.h"

#include <algorithm>
#include <iterator>

#include "tcpsockets/TCPAcceptor.h"
#include "tcpsockets/TCPConnector.h"
#include "Log.h"

using namespace nt;

ATOMIC_STATIC_INIT(Dispatcher)

void Dispatcher::StartServer(StringRef persist_filename,
                             const char* listen_address, unsigned int port) {
  DispatcherBase::StartServer(persist_filename,
                              std::unique_ptr<NetworkAcceptor>(new TCPAcceptor(
                                  static_cast<int>(port), listen_address)));
}

void Dispatcher::StartClient(const char* server_name, unsigned int port) {
  std::string server_name_copy(server_name);
  DispatcherBase::StartClient([=]() -> std::unique_ptr<NetworkStream> {
    return TCPConnector::connect(server_name_copy.c_str(),
                                 static_cast<int>(port), 1);
  });
}

Dispatcher::Dispatcher()
    : Dispatcher(Storage::GetInstance(), Notifier::GetInstance()) {}

{'fraction_non_alphanumeric': 0.20454545454545456, 'fraction_numerical': 0.003443526170798898, 'mean_word_length': 1.7825670498084292, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1412633', 'n_tokens_mistral': 714, 'n_tokens_neox': 673, 'n_words': 172}