You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/10/25 17:06:26 UTC

cvs commit: xml-xerces/c/src/util/regx RangeTokenMap.cpp

tng         01/10/25 08:06:26

  Modified:    c/src/util/regx RangeTokenMap.cpp
  Log:
  Thread safe the static instance.
  
  Revision  Changes    Path
  1.5       +15 -6     xml-xerces/c/src/util/regx/RangeTokenMap.cpp
  
  Index: RangeTokenMap.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/regx/RangeTokenMap.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RangeTokenMap.cpp	2001/10/23 23:13:41	1.4
  +++ RangeTokenMap.cpp	2001/10/25 15:06:26	1.5
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: RangeTokenMap.cpp,v $
  + * Revision 1.5  2001/10/25 15:06:26  tng
  + * Thread safe the static instance.
  + *
    * Revision 1.4  2001/10/23 23:13:41  peiyongz
    * [Bug#880] patch to PlatformUtils:init()/term() and related. from Mark Weaver
    *
  @@ -271,14 +274,20 @@
   //  RangeTokenMap: Instance methods
   // ---------------------------------------------------------------------------
   RangeTokenMap* RangeTokenMap::instance() {
  -	static XMLRegisterCleanup instanceCleanup;
  +    static XMLRegisterCleanup instanceCleanup;
   
  -	if (!fInstance) {
  +    if (!fInstance) {
  +        RangeTokenMap* t = new RangeTokenMap();
  +        if (XMLPlatformUtils::compareAndSwap((void **)&fInstance, t, 0) != 0)
  +        {
  +            delete t;
  +        }
  +        else
  +        {
  +            instanceCleanup.registerCleanup(reinitInstance);
  +        }
   
  -		fInstance = new RangeTokenMap();
  -		instanceCleanup.registerCleanup(reinitInstance);
  -	}
  -	
  +    }
       return (fInstance);
   }
   
  
  
  

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