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:18:18 UTC

cvs commit: xml-xerces/c/src/framework XMLValidator.hpp XMLValidator.cpp

peiyongz    01/11/30 14:18:18

  Modified:    c/src/framework XMLValidator.hpp XMLValidator.cpp
  Log:
  cleanUp function made member function
  cleanUp object moved to file scope
  double mutex lock removed
  
  Revision  Changes    Path
  1.17      +6 -1      xml-xerces/c/src/framework/XMLValidator.hpp
  
  Index: XMLValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/framework/XMLValidator.hpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- XMLValidator.hpp	2001/11/13 13:24:46	1.16
  +++ XMLValidator.hpp	2001/11/30 22:18:18	1.17
  @@ -56,6 +56,11 @@
   
    /*
     * $Log: XMLValidator.hpp,v $
  +  * Revision 1.17  2001/11/30 22:18:18  peiyongz
  +  * cleanUp function made member function
  +  * cleanUp object moved to file scope
  +  * double mutex lock removed
  +  *
     * Revision 1.16  2001/11/13 13:24:46  tng
     * Deprecate function XMLValidator::checkRootElement.
     *
  @@ -422,7 +427,9 @@
       // -----------------------------------------------------------------------
       //  Notification that lazy data has been deleted
       // -----------------------------------------------------------------------
  -	static void reinitXMLValidator();
  +	static void reinitMsgMutex();
  +
  +	static void reinitMsgLoader();
   
   protected :
       // -----------------------------------------------------------------------
  
  
  
  1.13      +52 -44    xml-xerces/c/src/framework/XMLValidator.cpp
  
  Index: XMLValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/framework/XMLValidator.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLValidator.cpp	2001/11/28 20:32:49	1.12
  +++ XMLValidator.cpp	2001/11/30 22:18:18	1.13
  @@ -56,6 +56,11 @@
   
   /**
     * $Log: XMLValidator.cpp,v $
  +  * Revision 1.13  2001/11/30 22:18:18  peiyongz
  +  * cleanUp function made member function
  +  * cleanUp object moved to file scope
  +  * double mutex lock removed
  +  *
     * Revision 1.12  2001/11/28 20:32:49  tng
     * Do not increment the error count if it is a warning.
     *
  @@ -122,8 +127,11 @@
   // ---------------------------------------------------------------------------
   //  Local static functions
   // ---------------------------------------------------------------------------
  +
  +static XMLMutex* sMsgMutex = 0;
  +static XMLRegisterCleanup msgLoaderCleanup;
   
  -static XMLMutex* validatorMutex = 0;
  +static XMLMsgLoader* sMsgLoader = 0;
   static XMLRegisterCleanup validatorMutexCleanup;
   
   //
  @@ -132,38 +140,43 @@
   //
   static XMLMutex& gValidatorMutex()
   {
  -    if (!validatorMutex)
  +    if (!sMsgMutex)
       {
           XMLMutex* tmpMutex = new XMLMutex;
  -        if (XMLPlatformUtils::compareAndSwap((void**)&validatorMutex, tmpMutex, 0))
  +        if (XMLPlatformUtils::compareAndSwap((void**)&sMsgMutex, tmpMutex, 0))
           {
               // Someone beat us to it, so let's clean up ours
               delete tmpMutex;
           }
           else
           {
  -            validatorMutexCleanup.registerCleanup(XMLValidator::reinitXMLValidator);
  +            validatorMutexCleanup.registerCleanup(XMLValidator::reinitMsgMutex);
           }
       }
   
  -    return *validatorMutex;
  +    return *sMsgMutex;
   }
   
   static XMLMsgLoader& getMsgLoader()
   {
  -    static XMLMsgLoader* gMsgLoader = 0;
   
  -    if (!gMsgLoader)
  -    {
  -        XMLMutexLock lockInit(&gValidatorMutex());
  -        if (!gMsgLoader)
  -        {
  -            gMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgValidityDomain);
  -            if (!gMsgLoader)
  -                XMLPlatformUtils::panic(XMLPlatformUtils::Panic_CantLoadMsgDomain);
  -        }
  -    }
  -    return *gMsgLoader;
  +	// Lock the mutex
  +	XMLMutexLock lockInit(&gValidatorMutex());
  +    
  +    if (!sMsgLoader)
  +	{
  +		sMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgValidityDomain);
  +		if (!sMsgLoader)
  +			XMLPlatformUtils::panic(XMLPlatformUtils::Panic_CantLoadMsgDomain);
  +
  +        //
  +        // Register this XMLMsgLoader for cleanup at Termination.
  +        //
  +        msgLoaderCleanup.registerCleanup(XMLValidator::reinitMsgLoader);
  +	
  +	}
  +
  +    return *sMsgLoader;
   }
   
   
  @@ -190,13 +203,10 @@
           const unsigned int msgSize = 1023;
           XMLCh errText[msgSize + 1];
   
  -        // Lock the mutex and load the text
  -        {
  -            XMLMutexLock lockInit(&gValidatorMutex());
  -            if (!getMsgLoader().loadMsg(toEmit, errText, msgSize))
  -            {
  -                // <TBD> Probably should load a default msg here
  -            }
  +        // load the text
  +		if (!getMsgLoader().loadMsg(toEmit, errText, msgSize))
  +		{
  +			// <TBD> Probably should load a default msg here
           }
   
           //
  @@ -251,13 +261,10 @@
           const unsigned int maxChars = 2047;
           XMLCh errText[maxChars + 1];
   
  -        // Lock the mutex and load the text
  -        {
  -            XMLMutexLock lockInit(&gValidatorMutex());
  -            if (!getMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
  -            {
  -                // <TBD> Should probably load a default message here
  -            }
  +        // load the text
  +		if (!getMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
  +		{
  +			// <TBD> Should probably load a default message here
           }
   
           //
  @@ -312,13 +319,10 @@
           const unsigned int maxChars = 2047;
           XMLCh errText[maxChars + 1];
   
  -        // Lock the mutex and load the text
  -        {
  -            XMLMutexLock lockInit(&gValidatorMutex());
  -            if (!getMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
  -            {
  -                // <TBD> Should probably load a default message here
  -            }
  +        // load the text
  +		if (!getMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
  +		{
  +			// <TBD> Should probably load a default message here
           }
   
           //
  @@ -369,11 +373,17 @@
   // -----------------------------------------------------------------------
   //  Notification that lazy data has been deleted
   // -----------------------------------------------------------------------
  -void XMLValidator::reinitXMLValidator() {
  -
  -    delete validatorMutex;
  -    validatorMutex = 0;
  -
  +void XMLValidator::reinitMsgMutex()
  +{
  +    delete sMsgMutex;
  +    sMsgMutex = 0;
   }
   
  -
  +// -----------------------------------------------------------------------
  +//  Reinitialise the message loader
  +// -----------------------------------------------------------------------
  +void XMLValidator::reinitMsgLoader()
  +{
  +	delete sMsgLoader;
  +	sMsgLoader = 0;
  +}
  
  
  

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