|
Boost Users : |
Subject: Re: [Boost-users] sending large serialized objects over network
From: Brian Wood (woodbrian77_at_[hidden])
Date: 2011-10-30 17:12:37
Jonathan Bishop:
> HI,
> I am involved in a project which requires the transport of large C++
> instances over MPI communication channels. I am using boost serialization
to
> pack and unpack the objects into a buffer. The whole buffer is sent in one
> shot.
>
> Of course for large objects this can be problematic. I have two
questions...
>
> 1) is there any way to tell beforehand how large the buffer needs to be?
In
> other words, can you run serialization in a counting only mode?
I'm not sure about the Boost Serialization library, but the C++
Middleware Writer counts the number of bytes in a message
before any is marshalled.
Here's an example
void
remote_messages::Marshal (SendCompressedBuffer& buf
, marshalling_integer const& abt1
, marshalling_integer const& abt2
, cmw_user_input const& abt3
)
{
Counter cntr(msg_length_max);
abt1.CalculateMarshallingSize(cntr);
abt2.CalculateMarshallingSize(cntr);
abt3.CalculateMarshallingSize(cntr);
cntr.Add(sizeof(msg_id_direct));
buf.Receive(&msg_id_direct, sizeof(msg_id_direct));
abt1.Marshal(buf, false);
abt2.Marshal(buf, false);
abt3.Marshal(buf, false);
}
-- Brian Wood Ebenezer Enterprises http://webEbenezer.net <http://webebenezer.net/>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net