messagingfw/msgsrvnstore/server/src/msvsearchsortcachemanager.cpp
branchRCL_3
changeset 6 fe71b07a6401
parent 0 8e480a14352b
child 22 d2c4c66342f3
--- a/messagingfw/msgsrvnstore/server/src/msvsearchsortcachemanager.cpp	Tue Feb 02 10:12:21 2010 +0200
+++ b/messagingfw/msgsrvnstore/server/src/msvsearchsortcachemanager.cpp	Fri Feb 19 23:18:09 2010 +0200
@@ -58,6 +58,7 @@
   */
  CMSvSearchSortCacheManager::~CMSvSearchSortCacheManager()
  	{
+	iOutstandingSOSOperations = 0;
 	iMsvIdWithSortFieldArray.Close();
 	iToFindResultAsIdArray.Close();
 	iFinalResultAsIdArray.Close();
@@ -144,6 +145,10 @@
 	iProgress = KMsvSearchSortOpNone;
 	iCancelFlag = EFalse;
 	iExplicitSortOnDateTime = EFalse;
+
+	//For Simultaneously query
+	iOutstandingSOSOperations = 0;
+	
 	if(CMsvEntryFreePool::Instance()->iMsvMaximumCacheSize != NULL && CMsvEntryFreePool::Instance()->iMsvSearchSortCache)
 		{
 		iMsvMaximumSearchSortCacheSize = ((CMsvEntryFreePool::Instance()->iMsvMaximumCacheSize * CMsvEntryFreePool::Instance()->iMsvSearchSortCache)/100)*1024 ;		
@@ -912,6 +917,10 @@
 			FinalResultAsIdL(aEntry);
 			iReturnResultType = KFinalResult;
 			iProgress = KMsvSearchSortOpCompleted; 
+			if(iOutstandingSOSOperations>0)
+				{
+				iOutstandingSOSOperations--;
+				}
 			}
 		else
 			{
@@ -937,6 +946,10 @@
 			{
 			FirstResultForInteraratorNewQueryL(aEntry);
 			iReturnResultType = KFinalResult;
+			if(iOutstandingSOSOperations>0)
+				{
+				iOutstandingSOSOperations--;
+				}
 			}
 #endif
 		else 
@@ -986,6 +999,10 @@
 			OnDemandUpdateCacheEntryL(aIndex);
 			iReturnResultType = KFinalResult;
 			iProgress = KMsvSearchSortOpCompleted; 
+			if(iOutstandingSOSOperations>0)
+				{
+				iOutstandingSOSOperations--;
+				}
 			}
 		else
 			{
@@ -993,7 +1010,11 @@
 			if(!iSearchSortDeltaCache->iDeltaCacheDirtyFlag)
 				{
 				iReturnResultType = KFinalResult;
-				iProgress = KMsvSearchSortOpCompleted;  
+				iProgress = KMsvSearchSortOpCompleted;
+				if(iOutstandingSOSOperations>0)
+					{
+					iOutstandingSOSOperations--;
+					}
 				}
 			else
 				{
@@ -1026,7 +1047,11 @@
 			FirstResultForInteraratorQueryIdL(aIndex);
 			iReturnResultType = KFinalResult;
 			iProgress = KMsvSearchSortOpIterationEnabled;
-			}
+			if(iOutstandingSOSOperations>0)
+				{
+				iOutstandingSOSOperations--;
+				}
+ 			}
 		else 
 			{
 			// Not Supported.
@@ -1344,6 +1369,10 @@
 	iSearchDbAdapter->GetSortedTMsvIdsfromTableL((*iManagerEntry)[aIndex-1]->iQueryID,iMsvSearchSortCacheManager->iFinalResultAsIdArray, (*iManagerEntry)[aIndex-1]->IsAscendingSort()/*Default = EFalse*/,(*iManagerEntry)[aIndex-1]->iMsgExplicitSortPart);
 	iReturnResultType = KFinalResult;
 	iProgress = KMsvSearchSortOpCompleted; 
+	if(iOutstandingSOSOperations>0)
+		{
+		iOutstandingSOSOperations--;
+		}
 	aToUpdateDb.Reset();
 	}
 
@@ -1365,6 +1394,10 @@
 		iProgress = KMsvSearchSortOpCompleted; 
 		}
 	iMsvSearchSortCacheManager->iMsvIdWithSortFieldArray.Reset();
+    if(iOutstandingSOSOperations>0)
+        {
+        iOutstandingSOSOperations--;
+        }
 	return iReturnResultType;
 	}
 
@@ -1403,6 +1436,10 @@
  		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry);
 #endif 		
   		iProgress = KMsvSearchSortOpCompleted;
+		if(iOutstandingSOSOperations>0)
+			{
+			iOutstandingSOSOperations--;
+			}
  		}
 	else
 		{
@@ -1412,6 +1449,10 @@
 		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry);
 #endif
 		iProgress = KMsvSearchSortOpCompleted;
+		if(iOutstandingSOSOperations>0)
+			{
+			iOutstandingSOSOperations--;
+			}
 		}
 	}
 
@@ -1433,12 +1474,20 @@
  		//iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID);
  		iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID, (*iManagerEntry)[index]->IsAscendingSort(), (*iManagerEntry)[index]->iMsgExplicitSortPart);
   		iProgress = KMsvSearchSortOpCompleted;
- 		}
+		if(iOutstandingSOSOperations>0)
+			{
+			iOutstandingSOSOperations--;
+			}
+   		}
 	else
 		{
 		//iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID);
 		iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID, (*iManagerEntry)[index]->IsAscendingSort(), (*iManagerEntry)[index]->iMsgExplicitSortPart);
 		iProgress = KMsvSearchSortOpCompleted;
+		if(iOutstandingSOSOperations>0)
+			{
+			iOutstandingSOSOperations--;
+			}
 		}
 	}
 
@@ -1459,6 +1508,13 @@
  		//iSearchDbAdapter->GetNextIdL( (*iManagerEntry)[aIndex]->iQueryID , iIteratorId,iIteratorRemainingResultCount);
  		iSearchDbAdapter->GetNextIdL(iIteratorId,iIteratorRemainingResultCount);
  		iProgress = KMsvSearchSortOpCompleted;
+		if(iIteratorRemainingResultCount == 0)
+			{
+			if(iOutstandingSOSOperations>0)
+				{
+				iOutstandingSOSOperations--;
+				}
+			}
  		}
 	else
 		{
@@ -1469,6 +1525,13 @@
 		iServer.IndexAdapter().GetEntry(iIteratorId,entry);
 		iIteratorEntry  = *entry;
 		iProgress = KMsvSearchSortOpCompleted;
+		if(iIteratorRemainingResultCount == 0)
+			{
+			if(iOutstandingSOSOperations>0)
+				{
+				iOutstandingSOSOperations--;
+				}
+       		}
 		}
 	}
 
@@ -1550,6 +1613,10 @@
 TInt CMSvSearchSortCacheManager::CancelSearchSortOperation() const
 	{
 	iMsvSearchSortCacheManager->iCancelFlag = ETrue;	
+	if(iOutstandingSOSOperations>0)
+		{
+		iOutstandingSOSOperations--;
+		}
 	return 0;
 	}
 
@@ -1638,3 +1705,16 @@
 	return iSearchDbAdapter;
 	}
 
+//For Simultaneously query
+void CMSvSearchSortCacheManager::AddOutstandingSOSOperation()
+    {
+    iOutstandingSOSOperations++;
+    }
+
+TInt CMSvSearchSortCacheManager::OutstandingSOSOperations()
+    {
+    return iOutstandingSOSOperations;
+    }
+ 
+
+