Пример #1
0
bool is_test_action(hpx::parcelset::parcel const& p)
{
    return dynamic_cast<
            hpx::actions::transfer_action<test_action>*
        >(p.get_action()) != nullptr;
}
Пример #2
0
void test_parcel_serialization(hpx::parcelset::parcel outp,
    int out_archive_flags, bool zero_copy)
{
    // serialize data
    std::vector<hpx::serialization::serialization_chunk> out_chunks;
    std::size_t arg_size = get_archive_size(outp, out_archive_flags,
        zero_copy ? &out_chunks : nullptr);
    std::vector<char> out_buffer;

    out_buffer.resize(arg_size + HPX_PARCEL_SERIALIZATION_OVERHEAD);

    {
        // create an output archive and serialize the parcel
        hpx::serialization::output_archive archive(
            out_buffer, out_archive_flags,
            zero_copy ? &out_chunks : nullptr);
        archive << outp;

        arg_size = archive.bytes_written();
    }

    out_buffer.resize(arg_size);

    // deserialize data
    hpx::parcelset::parcel inp;

    {
        // create an input archive and deserialize the parcel
        hpx::serialization::input_archive archive(
            out_buffer, arg_size, &out_chunks);

        archive >> inp;
    }

    // make sure the parcel has been de-serialized properly
    HPX_TEST_EQ(outp.source_id(), inp.source_id());
    HPX_TEST_EQ(outp.destination_locality(), inp.destination_locality());
    HPX_TEST_EQ(outp.start_time(), inp.start_time());

    hpx::actions::base_action *outact = outp.get_action();
    hpx::actions::base_action *inact = inp.get_action();

    HPX_TEST_EQ(outact->get_component_type(), inact->get_component_type());
    HPX_TEST_EQ(outact->get_action_name(), inact->get_action_name());
    HPX_TEST_EQ(int(outact->get_action_type()), int(inact->get_action_type()));
    HPX_TEST_EQ(outact->get_parent_locality_id(), inact->get_parent_locality_id());
    HPX_TEST_EQ(outact->get_parent_thread_id(), inact->get_parent_thread_id());
    HPX_TEST_EQ(outact->get_parent_thread_phase(), inact->get_parent_thread_phase());
    HPX_TEST_EQ(int(outact->get_thread_priority()), int(inact->get_thread_priority()));
    HPX_TEST_EQ(int(outact->get_thread_stacksize()), int(inact->get_thread_stacksize()));
    HPX_TEST_EQ(outact->get_parent_thread_phase(), inact->get_parent_thread_phase());

    std::unique_ptr<hpx::actions::continuation> outcont = outp.get_continuation();
    std::unique_ptr<hpx::actions::continuation> incont = inp.get_continuation();

    HPX_TEST_EQ(outcont->get_continuation_name(), incont->get_continuation_name());
    HPX_TEST_EQ(outcont->get_id(), incont->get_id());

    //// invoke action encapsulated in inp
    //naming::address const* inaddrs = pin.get_destination_addrs();
    //hpx::threads::thread_init_data data;
    //inact->get_thread_init_data(inaddrs[0].address_, data);
    //data.func(hpx::threads::wait_signaled);
}