
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Thursday, June 17, 2010 12:20 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] Sometimes Fails Reading BinaryFile
Robert McCullough wrote:
Steven,
Does the Serialization library support multi-thread application. My application uses boost::archive::binary_iarchive and boost::archive::binary_oarchive to serialize data to/from files in several different threads.
What could this mean?
That multiple threads read/write to the same open archive? Of course this could never make sense.
That multiple archives are being used simultaneously by different threads? As far as I know, subject to the following, there should be no problem.
[Robert McCullough] It means that multiple archives are being used simultaneously by different threads. Ok, this seems to work. I removed all the other archives from the threads so that there is only one archive. I still have my problem, so I don't think this is my issue.
a) If serialization code for some class is in a DLL and this DLL is dynamically loaded/unloaded while some other archive is open and being used by a separate thread, there could be a problem. This would be due to the fact that there is global list of types which is updated when a DLL is loaded and/or unloaded.
[Robert McCullough] Ok, I am not using DLL's.
b) xml_iarchives depend upon spirit which is not guarenteed thread-safe. I looked at the spirit code and believe that I selected that part which was thread-safe. But at least one user noted an issue with loading multiple xml_iarchives from separate threads.
[Robert McCullough] Ok. I will keep that in mind if I use xml_iarchives.
I believe this might be happing at the same time. Could this be causing my problem?
This question suggests to me that you're going about addressing your problem in totally the wrong way. I would suggest you make a unit test for your serialization code. Look at the tests in the serialization library for inspiration. This might seem like extra work - but it's not. It saves time. Do the following.
a) Make a one or more small test programs which test JUST the serialization of your classes. b) Run these test programs on ALL the archive classes in the the library including text and xml. If your serialization functions are correctly written, the ALL archive classes should work. c) Consider making a separate test program for each class. On my system, anytime I make a change in one class, all tests using that class are automatically recompiled and re-run. This saves huge amounts of wasted time in the future.
I seem to recall that one problem is that you were using binary_archive to
[Robert McCullough] Ok, thanks for the advice. try
to read archives created on a different platform. This is not supported by the binary_archive - and this is clearly stated in the documentation. If you're doing this, this can never work.
[Robert McCullough] Yes, I realized that this would not work on different platforms. I was just testing my code on different platforms to see if the bug happened on both. Then I realized I could not read the same archive file on both platforms.
Robert Ramey
Thanks, Robert
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users