Your main program, should just call Initialize(). When the program end, the
main program can just call Terminate(). In fact, you don't have to call
Terminate(). Its just a convenience for folks who want to do leak checking.
All it does is clean up global/static data that was lazily faulted in.

Part of the reason its not reentrant is that it cannot use its own mutex
abstraction until that support is initialized, but its not initilized until
Initialize() is already called. In order to support this, we'd have to put
per-platform support in each platform to support the init/term in a
threadsafe way, so that they could each use their own platform specific
synchronization to handle the serializing of the init/term work. That just
hasn't been done yet.

Another option is to add support in each platform to threadsafe swap in one
primitive mutex, which is never used in a nested way. It would only be
available via a getter method which would handle faulting it in, using
atomic compare and swap operations. This one primitive synchronization
mechanism would then be used to bootstrap up other stuff safely.

--------------
Dean Roddey
Software Geek Extraordinaire
Portal, Inc
[EMAIL PROTECTED]



-----Original Message-----
From: Scott A. Herod [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 30, 2001 11:21 AM
To: [EMAIL PROTECTED]
Subject: How to make it reentrant?


Hello,

  I watched the discussion about Xerces-C being reentrant a bit ago.
( It seems that archive.covalent.net is not answering the phone anymore
so I've not searched the archive again. )

The faq says:
"No. XMLPlatformUtils::Initialize() can only be called once per
process. Call Initialize() when you start and Terminate() when
you end."

Looking through the code in PlatformUtils.cpp it looks like you
can safely call Terminate as long as there is always one open 
Initialization.  That is because both Terminate and Initialize
watch a variable gInitFlag and return immediately if it is bigger
than 0 ( or 1 ).

I've got a multi-threaded app that makes use of several modules
dynamically linked at runtime.  Many of the modules make use
of XML based configuration files.  It appears that the modules 
can all call Initialize and Terminate safely provided that the
main app. has called Initialize prior to the modules being loaded
and if the main app. does not call Terminate while it is possible 
that another module will run.

Does that sound correct?

Secondly, is it use the atomicOpsMutex.fHandle that causes
problems with the Init and Term being reentrant in the Linux
code?

Thanks,

Scott

---------------------------------------------------------------------
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