[xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue
tomislav.reichenbach at valida.at
tomislav.reichenbach at valida.at
Mon Mar 5 04:57:22 EST 2012
Hello,
I have a problem using CodeSythesis XSD - CXX Tree generated classes when
using generated serialization functions from more threads.
Basically, the setup is following, the code is compiled as dlls and then
deployed on server. The Dlls are loaded only once and upon loading the
xercesc::XMLPlatformUtils::Initialize () is called (once). (On shutdown
the xercesc::XMLPlatformUtils::Terminate () is called to release the
library.) This is in line with the "3.4 Thread Safety" chapter from "
C++/Tree Mapping Getting Started Guide".
Normally everything works perfect. However, during the last/stress testing
with particular configuration there were problems. To reproduce the
errors, the thread count should be 20+ , and objects to be serialized
shoud be sufficiently large (requiring more than 1s per serialization
call). The serialized xml is then sometimes (roughly 75%) incomplete --
the last part is missing (not always the same tags).
Introducing a mutex before serialization prevents errors, but I have an
usage question, is this supposed to be so ?
To me this FAQ part is unclear :
"XSD-generated code is thread-safe in the sense that you can use different
instantiations of the object model in several threads concurrently. This
is possible due to the generated code not relying on any writable global
variables. If you need to share the same object between several threads
then you will need to provide some form of synchronization."
Per thread the order of executions is as follows:
string calculate(string input_xml) {
input xml->istringstream->create input objects
--- do some suff with objects ---
output object->serialize-> output xml
return output_xml
}
There are no shared (global, static or singleton) objects in the calculate
function.
Another remark, I have not been able to reproduce this error on my
development machine (Core 2 Duo, winXP), only on server (4xCPU, win2003
server).
Thanks.
Best regards
Tom
More information about the xsd-users
mailing list