Boris Kolpackov wrote:
Hi James,

James Berry <[EMAIL PROTECTED]> writes:

But I did see at least one use of the compareAndSwap routine, somewhere
in the transcoder support, I believe, though I didn't look into that
usage to see if it's really necessary.

That's a bummer. compareAndSwap is used in TransService.cpp,
WinSock/BinHTTPURLInputSource.cpp, and DOMDocumentTypeImpl.cpp.
The first case can be converted to use fgAtomicMutex as is done
in other places. For WinSock/BinHTTPURLInputSource we can hard-
code Window API calls or use fgAtomicMutex as well (BTW, even
with correct comareAndSwap code in BinHTTPURLInputSource is not
thread-safe on some architectures). The last case should probably
use static initialization. Any thoughts?
The use in TransService.cpp doesn't make much sense to me. The transcoding service is created through XMLPlatformUtils::Initialize(), and we've never claimed that's thread-safe. I also agree that that compareAndSwap() is not thread-safe, since there's no implicit memory barrier. Unfortunately, double-checked locking is everywhere in Xerces-C, so we should use this chance to get rid of one instance of it.

Is it possible we can do static initialization of XMLTransService through the regular static initialization process? I don't see the harm in it, but may be someone else does? We should try to do the same with BinHTTPURLInputSource.


The compareAndSwap routine interface is better, as it swaps void*,
which is at least a reasonable type.

We will still have to deal with the insane implementation on POSIX
systems.
I'd say if we can get rid of both atomicIncrement/atomicDecrement and compareAndSwap we should do it. With ever-increasing processor core counts, it's just a matter of time before we'ed have to deal with it anyway.

Dave

Boris

--
Boris Kolpackov, Code Synthesis Tools
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to