Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-06-29 11:57:17


Sigurd Saue wrote:
> We use boost serialization for sending notifications from a server to
> multiple clients. The problematic scenario is when two client threads
> within the same process deserializes the same notification. In your
> words: the same archive into different object from different threads.

Hmm this same archive or same archive instance? In any case I believe the
following should work and would be very interested in knowing that it
doesn't. If it doesn't work, I would be very interested in knowing where
the problem arises.

std::ifstream is1("file);
boost::archive::text_iarchive ia1(is1);

std::ifstream is2("file);
boost::archive::text_iarchive ia2(is2);

// from thread one
object o;
ia >> o

// from thread two
object o1;
ia1 >> o1;

Of course if the archives or their input streams are shared among threads
this can't work as the state of both the archives and streams are changed by
the action of deserialization.

Robert Ramey


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