
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. 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. 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.
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 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 Ramey
Thanks, Robert