You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2001/11/30 23:19:56 UTC

cvs commit: xml-xerces/c/src/util XMLException.hpp XMLException.cpp

peiyongz    01/11/30 14:19:56

  Modified:    c/src/util XMLException.hpp XMLException.cpp
  Log:
  cleanUp function made member function
  cleanUp object moved to file scope
  
  Revision  Changes    Path
  1.7       +7 -1      xml-xerces/c/src/util/XMLException.hpp
  
  Index: XMLException.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/XMLException.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLException.hpp	2001/11/21 16:15:33	1.6
  +++ XMLException.hpp	2001/11/30 22:19:56	1.7
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLException.hpp,v 1.6 2001/11/21 16:15:33 tng Exp $
  + * $Id: XMLException.hpp,v 1.7 2001/11/30 22:19:56 peiyongz Exp $
    */
   
   #if !defined(EXCEPTION_HPP)
  @@ -121,6 +121,12 @@
       XMLException(const XMLException& toCopy);
       void operator=(const XMLException& toAssign);
   
  +    // -----------------------------------------------------------------------
  +    //  Notification that lazy data has been deleted
  +    // -----------------------------------------------------------------------
  +	static void reinitMsgMutex();
  +
  +	static void reinitMsgLoader();
   
   protected :
       // -----------------------------------------------------------------------
  
  
  
  1.8       +52 -64    xml-xerces/c/src/util/XMLException.cpp
  
  Index: XMLException.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/XMLException.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLException.cpp	2001/10/23 23:09:32	1.7
  +++ XMLException.cpp	2001/11/30 22:19:56	1.8
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLException.cpp,v 1.7 2001/10/23 23:09:32 peiyongz Exp $
  + * $Id: XMLException.cpp,v 1.8 2001/11/30 22:19:56 peiyongz Exp $
    */
   
   
  @@ -92,29 +92,23 @@
   // ---------------------------------------------------------------------------
   //  Local, static data
   // ---------------------------------------------------------------------------
  -static XMLMsgLoader* sLoader = 0;
  +static XMLMsgLoader* sMsgLoader = 0;
  +static XMLRegisterCleanup msgLoaderCleanup;
  +
   static XMLMutex* sMsgMutex = 0;
  +static XMLRegisterCleanup msgMutexCleanup;
   
   // ---------------------------------------------------------------------------
   //  Local, static functions
   // ---------------------------------------------------------------------------
   
  -// -----------------------------------------------------------------------
  -//  Reinitialise the message mutex
  -// -----------------------------------------------------------------------
  -static void reinitMsgMutex()
  -{
  -	delete sMsgMutex;
  -	sMsgMutex = 0;
  -}
  -
   //
   //  We need to fault in this mutex. But, since its used for synchronization
   //  itself, we have to do this the low level way using a compare and swap.
   //
   static XMLMutex& gMsgMutex()
   {
  -	static XMLRegisterCleanup msgMutexCleanup;
  +
       if (!sMsgMutex)
       {
           XMLMutex* tmpMutex = new XMLMutex;
  @@ -126,54 +120,39 @@
           else
           {
               // This is the real mutex.  Register it for cleanup at Termination.
  -			msgMutexCleanup.registerCleanup(reinitMsgMutex);
  +			msgMutexCleanup.registerCleanup(XMLException::reinitMsgMutex);
           }
           
       }
  -    return *sMsgMutex;
  -}
  -
  -
   
  -// ---------------------------------------------------------------------------
  -//  Local methods
  -// ---------------------------------------------------------------------------
  -
  -// -----------------------------------------------------------------------
  -//  Reinitialise the message loader
  -// -----------------------------------------------------------------------
  -static void reinitMsgLoader()
  -{
  -	delete sLoader;
  -	sLoader = 0;
  +    return *sMsgMutex;
   }
   
   //
   //  This method is a lazy evaluator for the message loader for exception
   //  messages.
   //
  -//  NOTE:   This is only ever called with the mutex locked so we don't
  -//          have to synchronize here!!
  -//
   static XMLMsgLoader& gGetMsgLoader()
   {
  -	static XMLRegisterCleanup msgLoaderCleanup;
  +
  +    // Lock the message loader mutex and load the text
  +	XMLMutexLock lockInit(&gMsgMutex());
   
       // Fault it in on first request
  -    if (!sLoader)
  +    if (!sMsgLoader)
       {
  -        sLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgExceptDomain);
  -        if (!sLoader)
  +        sMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgExceptDomain);
  +        if (!sMsgLoader)
               XMLPlatformUtils::panic(XMLPlatformUtils::Panic_CantLoadMsgDomain);
   
           //
           // Register this XMLMsgLoader for cleanup at Termination.
           //
  -        msgLoaderCleanup.registerCleanup(reinitMsgLoader);
  +        msgLoaderCleanup.registerCleanup(XMLException::reinitMsgLoader);
       }
       
       // We got it, so return it
  -    return *sLoader;
  +    return *sMsgLoader;
   }
   
   // ---------------------------------------------------------------------------
  @@ -268,15 +247,12 @@
       const unsigned int msgSize = 2047;
       XMLCh errText[msgSize + 1];
   
  -    // Lock the message loader mutex and load the text
  -    {
  -        XMLMutexLock lockInit(&gMsgMutex());
  -        if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize))
  -        {
  -            fMsg = XMLString::replicate(gDefErrMsg);
  -            return;
  -        }
  -    }
  +    // load the text
  +	if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize))
  +	{
  +		fMsg = XMLString::replicate(gDefErrMsg);
  +		return;
  +	}
   
       // We got the text so replicate it into the message member
       fMsg = XMLString::replicate(errText);
  @@ -297,15 +273,12 @@
       const unsigned int msgSize = 4095;
       XMLCh errText[msgSize + 1];
   
  -    // Lock the message loader mutex and load the text
  -    {
  -        XMLMutexLock lockInit(&gMsgMutex());
  -        if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize, text1, text2, text3, text4))
  -        {
  -            fMsg = XMLString::replicate(gDefErrMsg);
  -            return;
  -        }
  -    }
  +    // load the text
  +	if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize, text1, text2, text3, text4))
  +	{
  +		fMsg = XMLString::replicate(gDefErrMsg);
  +		return;
  +	}
   
       // We got the text so replicate it into the message member
       fMsg = XMLString::replicate(errText);
  @@ -326,16 +299,31 @@
       const unsigned int msgSize = 4095;
       XMLCh errText[msgSize + 1];
   
  -    // Lock the message loader mutex and load the text
  -    {
  -        XMLMutexLock lockInit(&gMsgMutex());
  -        if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize, text1, text2, text3, text4))
  -        {
  -            fMsg = XMLString::replicate(gDefErrMsg);
  -            return;
  -        }
  -    }
  +    // load the text
  +	if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize, text1, text2, text3, text4))
  +	{
  +		fMsg = XMLString::replicate(gDefErrMsg);
  +		return;
  +	}
   
       // We got the text so replicate it into the message member
       fMsg = XMLString::replicate(errText);
   }
  +
  +// -----------------------------------------------------------------------
  +//  Reinitialise the message mutex
  +// -----------------------------------------------------------------------
  +void XMLException::reinitMsgMutex()
  +{
  +	delete sMsgMutex;
  +	sMsgMutex = 0;
  +}
  +
  +// -----------------------------------------------------------------------
  +//  Reinitialise the message loader
  +// -----------------------------------------------------------------------
  +void XMLException::reinitMsgLoader()
  +{
  +	delete sMsgLoader;
  +	sMsgLoader = 0;
  +}
  \ No newline at end of file
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org