merged_tuple::cow_ptr merged_tuple::make(message x, message y) {
  data_type data{x.vals(), y.vals()};
  mapping_type mapping;
  auto s = x.size();
  for (size_t i = 0; i < s; ++i) {
    if (x.match_element<index_mapping>(i))
      mapping.emplace_back(1, x.get_as<index_mapping>(i).value - 1);
    else
      mapping.emplace_back(0, i);
  }
  return cow_ptr{make_counted<merged_tuple>(std::move(data),
                                            std::move(mapping))};
}
Exemple #2
0
void peer::enqueue_impl(msg_hdr_cref hdr, const message& msg) {
    BOOST_ACTOR_LOG_TRACE("");
    auto tname = msg.tuple_type_names();
    add_type_if_needed((tname) ? *tname : detail::get_tuple_type_names(*msg.vals()));
    uint32_t size = 0;
    auto& wbuf = write_buffer();
    auto before = static_cast<uint32_t>(wbuf.size());
    binary_serializer bs(&wbuf, &(parent()->get_namespace()), &m_outgoing_types);
    wbuf.write(sizeof(uint32_t), &size);
    try { bs << hdr << msg; }
    catch (std::exception& e) {
        BOOST_ACTOR_LOG_ERROR(to_verbose_string(e));
        cerr << "*** exception in peer::enqueue; "
             << to_verbose_string(e)
             << endl;
        return;
    }
    BOOST_ACTOR_LOG_DEBUG("serialized: " << to_string(hdr) << " " << to_string(msg));
    size =   static_cast<std::uint32_t>((wbuf.size() - before))
           - static_cast<std::uint32_t>(sizeof(std::uint32_t));
    // update size in buffer
    memcpy(wbuf.offset_data(before), &size, sizeof(std::uint32_t));
}
Exemple #3
0
bool message::equals(const message& other) const {
  if (empty())
    return other.empty();
  return other.empty() ? false : vals_->equals(*other.vals());
}