Beispiel #1
0
// Delete a resource list.
void ResourceListSet::deleteResourceList(const char* user)
{
   Os::Logger::instance().log(FAC_RLS, PRI_DEBUG,
                 "ResourceListSet::deleteResourceList this = %p, user = '******'",
                 this, user);

   // Gradually remove elements from the ResourceList and delete them.
   ResourceList* rl;
   int changeDelay = getResourceListServer()->getChangeDelay();
   do {
      // Set to true if a ResourceCached was deleted and so we need to delay.
      bool resource_deleted = false;

      {
         // Serialize access to the ResourceListSet.
         OsLock lock(mSemaphore);

         // Get pointer to the ResourceList.
         rl = findResourceList(user);

         // If it exists, shrink it.
         if (rl) {
            bool list_empty;
            rl->shrink(list_empty, resource_deleted);
            if (list_empty) {
               // The ResourceList is empty, and so can be removed and deleted.
               mResourceLists.removeReference(rl);
               delete rl;
               // Exit the loop now.
               rl = NULL;
            }
         }
      }

      if (resource_deleted)
      {
         // Delay to allow the consequent processing to catch up.
         OsTask::delay(changeDelay);
      }
   } while (rl && !gShutdownFlag);
}
Beispiel #2
0
// Delete all resource lists.
void ResourceListSet::deleteAllResourceLists(bool abortOnShutdown)
{
   Os::Logger::instance().log(FAC_RLS, PRI_DEBUG,
                 "ResourceListSet::deleteAllResourceLists "
                 "this = %p, abortOnShutdown = %d",
                 this, abortOnShutdown);

   // Gradually remove elements from the ResourceLists and delete them.
   ResourceList* rl;
   int changeDelay = getResourceListServer()->getChangeDelay();
   do {
      // Set to true if a ResourceCached was deleted and so we need to delay.
      bool resource_deleted = false;

      {
         // Serialize access to the ResourceListSet.
         OsLock lock(mSemaphore);

         // Get pointer to the first ResourceList.
         rl = dynamic_cast <ResourceList*> (mResourceLists.first());

         // If one exists, shrink it.
         if (rl) {
            bool list_empty;
            rl->shrink(list_empty, resource_deleted);
            if (list_empty) {
               // The ResourceList is empty, and so can be removed and deleted.
               mResourceLists.removeReference(rl);
               delete rl;
            }
         }
      }

      if (resource_deleted)
      {
         // Delay to allow the consequent processing to catch up.
         OsTask::delay(changeDelay);
      }
   } while (rl && !gShutdownFlag);
}