(file) Return to SCMOClassCache.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/SCMOClassCache.cpp between version 1.1.2.5 and 1.1.2.7

version 1.1.2.5, 2009/11/05 11:15:09 version 1.1.2.7, 2009/12/03 15:53:26
Line 231 
Line 231 
     _cacheReadMiss++;     _cacheReadMiss++;
 #endif #endif
  
     CIMClass cc = _resolveCallBack(      SCMOClass tmp = _resolveCallBack(
          CIMNamespaceNameCast(String(nsName,nsNameLen)),          CIMNamespaceNameCast(String(nsName,nsNameLen)),
          CIMNameCast(String(className,classNameLen)));          CIMNameCast(String(className,classNameLen)));
  
      if (cc.isUninitialized())      if (tmp.isEmpty())
      {      {
          // The requested class was not found !          // The requested class was not found !
          // The modify lock is destroyed automaticaly !          // The modify lock is destroyed automaticaly !
          return SCMOClass();          return SCMOClass();
      }      }
  
      SCMOClass* scmoClass = new SCMOClass(cc,nsName);      SCMOClass* scmoClass = new SCMOClass(tmp);
  
      _lastWrittenIndex = (_lastWrittenIndex + 1)%PEGASUS_SCMO_CLASS_CACHE_SIZE;      _lastWrittenIndex = (_lastWrittenIndex + 1)%PEGASUS_SCMO_CLASS_CACHE_SIZE;
  
Line 311 
Line 311 
     {     {
       theKey = _generateKey(className,classNameLen,nsName,nsNameLen);       theKey = _generateKey(className,classNameLen,nsName,nsNameLen);
  
         // The counter i is never used as index.
         // It is used to ensure to look through all used entries.
       for (Uint32 i = 0; i < usedEntries; i++)       for (Uint32 i = 0; i < usedEntries; i++)
       {       {
           if(_lockEntry(nextIndex))           if(_lockEntry(nextIndex))
Line 356 
Line 358 
     return SCMOClass();     return SCMOClass();
 } }
  
   void SCMOClassCache::removeSCMOClass(
       CIMNamespaceName cimNameSpace,
       CIMName cimClassName)
   {
   
       if (cimClassName.isNull() || cimNameSpace.isNull())
       {
           return ;
       }
   
      CString nsName = cimNameSpace.getString().getCString();
      Uint32 nsNameLen = strlen(nsName);
      CString clsName = cimClassName.getString().getCString();
      Uint32 clsNameLen = strlen(clsName);
   
      // The number of used entries form 0 to PEGASUS_SCMO_CLASS_CACHE_SIZE
      Uint32 usedEntries = _fillingLevel % (PEGASUS_SCMO_CLASS_CACHE_SIZE + 1);
   
      Uint64  theKey = _generateKey(clsName,clsNameLen,nsName,nsNameLen);
   
      // A straight forward loop through all used entries,
      // ignoring the last success.
      for (Uint32 i = 0; i < usedEntries; i++)
      {
          if(_lockEntry(i))
          {
              // does the key match for the entry and the requested class ?
              if ( 0 != _theCache[i].key && theKey == _theCache[i].key)
              {
                  // To get sure we found the right class, compare name space
                  // and class name.
                  if (_sameSCMOClass(nsName,nsNameLen,clsName,clsNameLen,
                                     _theCache[i].data))
                  {
                      // Yes, we got it !
                      _theCache[i].key = 0;
                      delete _theCache[i].data;
                      _theCache[i].data = 0;
                      _unlockEntry(i);
                      return;
                  }
              }
              // It was the wrong entry, go to the next.
              _unlockEntry(i);
          }
          else
          {
              // We do not get the lock, if the cache is going to be destroyed.
              return;
          }
      }
   }
   
   void SCMOClassCache::clear()
   {
       WriteLock modifyLock(_modifyCacheLock);
   
       if ( _dying )
       {
           // The cache is going to be destroyed.
           return ;
       }
   
       // The number of used entries form 0 to PEGASUS_SCMO_CLASS_CACHE_SIZE
       Uint32 usedEntries = _fillingLevel % (PEGASUS_SCMO_CLASS_CACHE_SIZE + 1);
   
       // A straight forwar loop through all used entries,
       // ignoring the last success.
       for (Uint32 i = 0; i < usedEntries; i++)
       {
           if(_lockEntry(i))
           {
               _theCache[i].key = 0;
               delete _theCache[i].data;
               _theCache[i].data = 0;
               _unlockEntry(i);
           }
           else
           {
               // We do not get the lock, if the cache is going to be destroyed.
               return;
           }
       }
       // Reset all controll data
       _fillingLevel = 0;
       _lastSuccessIndex = 0;
       _lastWrittenIndex = PEGASUS_SCMO_CLASS_CACHE_SIZE-1;
   
   
   }
 #ifdef PEGASUS_DEBUG #ifdef PEGASUS_DEBUG
 void SCMOClassCache::DisplayCacheStatistics() void SCMOClassCache::DisplayCacheStatistics()
 { {
Line 385 
Line 477 
         const char* className,         const char* className,
         Uint32 classNameLen)         Uint32 classNameLen)
 { {
       if (nsName && className && nsNameLen && classNameLen)
       {
   
     PEGASUS_ASSERT(_resolveCallBack);     PEGASUS_ASSERT(_resolveCallBack);
  
      CIMClass cc = _resolveCallBack(  
             SCMOClass tmp = _resolveCallBack(
          CIMNamespaceNameCast(String(nsName,nsNameLen)),          CIMNamespaceNameCast(String(nsName,nsNameLen)),
          CIMNameCast(String(className,classNameLen)));          CIMNameCast(String(className,classNameLen)));
  
      if (cc.isUninitialized())            if (tmp->isEpmpty())
      {      {
          // The requested class was not found !          // The requested class was not found !
                  // The modify lock is destroyed automaticaly !
          return SCMOClass();          return SCMOClass();
      }      }
  
      return SCMOClass(cc,nsName);            return SCMOClass(tmp);
       }
   
       return SCMOClass();
  
 } }
  
 void SCMOClassCache::removeSCMOClass(CIMNamespaceName nsName,CIMName className)  void SCMOClassCache::removeSCMOClass(
       CIMNamespaceName cimNameSpace,
       CIMName cimClassName)
   {
   }
   
   
   void SCMOClassCache::clear()
 { {
 } }
  


Legend:
Removed from v.1.1.2.5  
changed lines
  Added in v.1.1.2.7

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2