userlibandfileserver/fileserver/sfile/sf_std.h
changeset 90 947f0dc9f7a8
parent 15 4122176ea935
child 102 ef2a444a7410
child 132 e4a7b1cbe40c
--- a/userlibandfileserver/fileserver/sfile/sf_std.h	Tue Feb 02 01:24:03 2010 +0200
+++ b/userlibandfileserver/fileserver/sfile/sf_std.h	Fri Apr 16 16:24:37 2010 +0300
@@ -1398,9 +1398,10 @@
 	TRequestStatus iStatus;
 	TBool iIsAllocated;
 	};
-const TInt KMaxRequestAllocated		= 45;
-const TInt KMaxOperationAllocated	= KMaxRequestAllocated * 2;
-const TInt KAllocReqBlock=15;
+
+// If the number of requests on the free queue reaches this value then completed requests 
+// are returned to the heap rather than being added to thefree queue
+const TInt KFreeCountMax = 64;
 
 class TParseCon
 	{
@@ -1413,34 +1414,53 @@
 class RequestAllocator
 	{
 public:
+	static TInt Initialise();
+
 	static TInt GetMessageRequest(const TOperation& aOperation,const RMessage2& aMessage,CFsClientMessageRequest* &aRequest);
-	static void FreeRequest(CFsClientMessageRequest* aRequest); // Use the one from cache
+	static void FreeRequest(CFsClientMessageRequest* aRequest);
 	static void OpenSubFailed(CSessionFs* aSession); 
-	static TInt AllocRequest(TInt aNum);
+
+#if defined(_USE_CONTROLIO) || defined(_DEBUG) || defined(_DEBUG_RELEASE)
+	inline static TInt RequestCount();
+	inline static TInt RequestCountPeak();
+	static TInt CloseCount();
+	static TInt FreeCount();
+#endif
+
+private:
+	static CFsClientMessageRequest* GetRequest();
 
-	static TInt AllocOperation();
+private:
+	static RFastLock iCacheLock;
+	static CFsClientMessageRequest* iFreeHead;				
+	static CFsClientMessageRequest* iCloseHead;
+
+	static TInt iRequestCount;			// current number of requests
+	static TInt iFreeCount;				// current number of requests on free queue
+	static TInt iRequestCountPeak;				// maximum value of requests reached
+	};
+
+class OperationAllocator
+	{
+public:
+	static TInt Initialise();
+
 	static TInt GetOperation(TMsgOperation* &aOperation);
 	static void FreeOperation(TMsgOperation* aOperation);
 
-
-	static void Initialise();
 #if defined(_USE_CONTROLIO) || defined(_DEBUG) || defined(_DEBUG_RELEASE)
-	inline static TInt TotalCount();
-	static TInt CloseCount();
-	static TInt FreeCount();
-	inline static TInt AllocatedCount();
-private:
-	static TInt iAllocated;
+	inline static TInt RequestCount();
+	inline static TInt RequestCountPeak();
+	inline static TInt FreeCount();
 #endif
-public:
-	static RFastLock iCacheLock;
+
 private:
-	static TInt iAllocNum;
-	static CFsClientMessageRequest* iFreeHead;				
-	static CFsClientMessageRequest* iCloseHead;
+	static RFastLock iCacheLock;
+	static TMsgOperation* iFreeHead;
 
-	static TInt iAllocNumOperation;
-	static TMsgOperation* iFreeHeadSupOp;
+	static TInt iRequestCount;			// current number of requests
+	static TInt iFreeCount;				// current number of requests on free queue
+	static TInt iRequestCountPeak;				// maximum value of requests reached
 	};
 
 
@@ -1511,6 +1531,7 @@
 	~CDismountNotifyInfo();
 	void Initialise(TNotifyDismountMode aMode, TInt aDriveNumber,TRequestStatus* iStatus,const RMessagePtr2& aMessage,CSessionFs* aSession);
 	TBool IsMatching(TNotifyDismountMode aMode, TInt aDriveNumber, CSessionFs* aSession);
+	inline TInt DriveNumber() {return iDriveNumber;}
 private:
 	TNotifyDismountMode iMode;
 	TInt iDriveNumber;
@@ -1527,6 +1548,7 @@
 	void DoAddNotify(CNotifyInfo* aInfo);
 	TBool DoCancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus=NULL);
 	void DoCancelAll(TInt aCompletionCode);
+	CNotifyInfo* DoFindEntry(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
 	TBool IsEmpty();
 protected:
 	TDblQue<CNotifyInfo> iHeader;
@@ -1597,7 +1619,7 @@
 	static void CancelChangeSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
 	static void CancelDiskSpaceSession(CSessionFs* aSession,TRequestStatus* aStatus=NULL);
 	static void CancelDebugSession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
-	static void CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
+	static TInt CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus=NULL);
 	static void CancelSession(CSessionFs* aSession);
 	static TBool HandlePendingDismount(CSessionFs* aSession, TInt aDriveNumber);
 	static TBool IsChangeQueEmpty(TInt aDrive);
@@ -1803,6 +1825,8 @@
 extern TInt UserHeapAllocFailCount;
 extern TInt KernHeapAllocFailCount;
 extern TInt MessageCount;
+extern TInt SessionCount;
+extern TInt ObjectCount;
 
 void PrintHeapSize(const TDesC& aMessage);