<commit_before>/******************************************************************************
 *                       ____    _    _____                                   *
 *                      / ___|  / \  |  ___|    C++                           *
 *                     | |     / _ \ | |_       Actor                         *
 *                     | |___ / ___ \|  _|      Framework                     *
 *                      \____/_/   \_|_|                                      *
 *                                                                            *
 * Copyright (C) 2011 - 2015                                                  *
 * <NAME> <<EMAIL>ik.charousset (at) haw-hamburg.de>                *
 *                                                                            *
 * Distributed under the terms and conditions of the BSD 3-Clause License or  *
 * (at your option) under the terms and conditions of the Boost Software      *
 * License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE.       *
 *                                                                            *
 * If you did not receive a copy of the license files, see                    *
 * http://opensource.org/licenses/BSD-3-Clause and                            *
 * http://www.boost.org/LICENSE_1_0.txt.                                      *
 ******************************************************************************/

#ifndef CAF_DETAIL_SPLIT_JOIN_HPP
#define CAF_DETAIL_SPLIT_JOIN_HPP

#include <vector>

#include "caf/actor.hpp"
#include "caf/locks.hpp"
#include "caf/spawn.hpp"
#include "caf/event_based_actor.hpp"

#include "caf/detail/shared_spinlock.hpp"

namespace caf {
namespace detail {

using actor_msg_vec = std::vector<std::pair<actor, message>>;

template <class T, class Split, class Join>
class split_join_collector : public event_based_actor {
 public:
  split_join_collector(T init_value, Split s, Join j, actor_msg_vec xs)
      : m_workset(std::move(xs)),
        m_awaited_results(m_workset.size()),
        m_join(std::move(j)),
        m_split(std::move(s)),
        m_value(std::move(init_value)) {
    // nop
  }

  behavior make_behavior() override {
    return {
      others >> [=] {
        m_rp = this->make_response_promise();
        m_split(m_workset, this->current_message());
        // first message is the forwarded request
        for (auto& x : m_workset) {
          this->sync_send(x.first, std::move(x.second)).then(
            others >> [=] {
              m_join(m_value, this->current_message());
              if (--m_awaited_results == 0) {<commit_msg>Fix build on GCC 4.7<commit_after>/******************************************************************************
 *                       ____    _    _____                                   *
 *                      / ___|  / \  |  ___|    C++                           *
 *                     | |     / _ \ | |_       Actor                         *
 *                     | |___ / ___ \|  _|      Framework                     *
 *                      \____/_/   \_|_|                                      *
 *                                                                            *
 * Copyright (C) 2011 - 2015                                                  *
 * <NAME> <dominik.charousset (at) haw-hamburg.de>                *
 *                                                                            *
 * Distributed under the terms and conditions of the BSD 3-Clause License or  *
 * (at your option) under the terms and conditions of the Boost Software      *
 * License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE.       *
 *                                                                            *
 * If you did not receive a copy of the license files, see                    *
 * http://opensource.org/licenses/BSD-3-Clause and                            *
 * http://www.boost.org/LICENSE_1_0.txt.                                      *
 ******************************************************************************/

#ifndef CAF_DETAIL_SPLIT_JOIN_HPP
#define CAF_DETAIL_SPLIT_JOIN_HPP

#include <vector>

#include "caf/actor.hpp"
#include "caf/locks.hpp"
#include "caf/spawn.hpp"
#include "caf/event_based_actor.hpp"

#include "caf/detail/shared_spinlock.hpp"

namespace caf {
namespace detail {

using actor_msg_vec = std::vector<std::pair<actor, message>>;

template <class T, class Split, class Join>
class split_join_collector : public event_based_actor {
 public:
  split_join_collector(T init_value, Split s, Join j, actor_msg_vec xs)
      : m_workset(std::move(xs)),
        m_awaited_results(m_workset.size()),
        m_join(std::move(j)),
        m_split(std::move(s)),
        m_value(std::move(init_value)) {
    // nop
  }

  behavior make_behavior() override {
    return {
      others >> [=] {
        m_rp = this->make_response_promise();
        m_split(m_workset, this->current_message());
        // first message is the forwarded request
        // GCC 4.7 workaround; `for (auto& x : m_workset)` doesn't compile
        for (size_t i = 0; i < m_workset.size(); ++i) {
          auto& x = m_workset[i];
          this->sync_send(x.first, std::move(x.second)).then(
            others >> [=] {
              m_join(m_value, this->current_message());
              if (--m_awaited_results == 0) {
{'fraction_non_alphanumeric': 0.15801186943620177, 'fraction_numerical': 0.006491097922848665, 'mean_word_length': 1.3979546465095598, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1672359', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1390, 'n_words': 291}