userlibandfileserver/fileserver/sfat32/fat_table32.cpp
branchRCL_3
changeset 268 345b1ca54e88
parent 257 3e88ff8f41d5
child 294 039a3e647356
equal deleted inserted replaced
263:9e2d4f7f5028 268:345b1ca54e88
  1034         if(pFatBitCache)
  1034         if(pFatBitCache)
  1035             {//-- bit cache is present, we need to populate (or repopulate it)
  1035             {//-- bit cache is present, we need to populate (or repopulate it)
  1036             //-- create helper thread object and start the thread
  1036             //-- create helper thread object and start the thread
  1037             ipHelperThread = CFat32BitCachePopulator::NewL(*this);
  1037             ipHelperThread = CFat32BitCachePopulator::NewL(*this);
  1038 
  1038 
  1039             ipHelperThread->Launch(); 
  1039             if(ipHelperThread->Launch() != KErrNone)
       
  1040                 {//-- failed for some reason
       
  1041                 DestroyHelperThread();
       
  1042                 }
       
  1043                 else
       
  1044                 {
  1040             //-- background FAT bit cache populating thread is running now.
  1045             //-- background FAT bit cache populating thread is running now.
  1041             //-- the result of thread start up and completion isn't very interesting: If it fails to 
  1046             //-- the result of thread start up and completion isn't very interesting: If it fails to 
  1042             //-- properly populate the cache, nothing fatal will happen.
  1047             //-- properly populate the cache, nothing fatal will happen.
       
  1048             }
  1043             }
  1049             }
  1044 
  1050 
  1045         //-- CFat32BitCachePopulator doesn't affect FAT table state. 
  1051         //-- CFat32BitCachePopulator doesn't affect FAT table state. 
  1046         SetState(EMounted);
  1052         SetState(EMounted);
  1047         return; 
  1053         return; 
  1470                 TInt nMntDebugFlags;
  1476                 TInt nMntDebugFlags;
  1471                 if(bFat32BkGndScan && RProperty::Get(KSID_Test1, iOwner->DriveNumber(), nMntDebugFlags) == KErrNone)
  1477                 if(bFat32BkGndScan && RProperty::Get(KSID_Test1, iOwner->DriveNumber(), nMntDebugFlags) == KErrNone)
  1472                 {//-- test property for this drive is defined
  1478                 {//-- test property for this drive is defined
  1473                     if(nMntDebugFlags & KMntDisable_FatBkGndScan)
  1479                     if(nMntDebugFlags & KMntDisable_FatBkGndScan)
  1474                     {
  1480                     {
  1475                     __PRINT(_L("#- FAT32 BkGnd scan is disabled is disabled by debug interface."));
  1481                     __PRINT(_L("#- FAT32 BkGnd scan is disabled by debug interface."));
  1476                     bFat32BkGndScan = EFalse;
  1482                     bFat32BkGndScan = EFalse;
  1477                     }
  1483                     }
  1478             
  1484             
  1479                 }
  1485                 }
  1480 #endif
  1486 #endif
  1534     //-- 2. create helper thread object and start the thread
  1540     //-- 2. create helper thread object and start the thread
  1535     ipHelperThread = CFat32FreeSpaceScanner::NewL(*this);
  1541     ipHelperThread = CFat32FreeSpaceScanner::NewL(*this);
  1536     
  1542     
  1537     SetState(EFreeClustersScan);
  1543     SetState(EFreeClustersScan);
  1538     
  1544     
  1539     ipHelperThread->Launch(); 
  1545     User::LeaveIfError(ipHelperThread->Launch()); 
       
  1546     
  1540     //-- background FAT scanning thread is running now
  1547     //-- background FAT scanning thread is running now
  1541     }
  1548     }
  1542 
  1549 
  1543 //-----------------------------------------------------------------------------
  1550 //-----------------------------------------------------------------------------
  1544 /**
  1551 /**
  1976 
  1983 
  1977 //-----------------------------------------------------------------------------
  1984 //-----------------------------------------------------------------------------
  1978 
  1985 
  1979 /**
  1986 /**
  1980     Launches the FAT32_ScanThread scaner thread.
  1987     Launches the FAT32_ScanThread scaner thread.
  1981     @return  standard error code
  1988     @return  KErrNone if the thread launched OK
       
  1989              standard error code otherwise
  1982 */
  1990 */
  1983 TInt CFat32ScanThread::Launch()
  1991 TInt CFat32ScanThread::Launch()
  1984     {
  1992     {
  1985     return DoLaunchThread(FAT32_ScanThread, this);    
  1993     return DoLaunchThread(FAT32_ScanThread, this);    
  1986     }
  1994     }
  2538 
  2546 
  2539 
  2547 
  2540             //-- allow this thread to be preempted by another one that wants to access the media driver.
  2548             //-- allow this thread to be preempted by another one that wants to access the media driver.
  2541             //-- without this wait we will have priority inversion, because this (low priority) thread continiously reads data by big chunks 
  2549             //-- without this wait we will have priority inversion, because this (low priority) thread continiously reads data by big chunks 
  2542             //-- and doesn't allow others to access the driver.
  2550             //-- and doesn't allow others to access the driver.
  2543             //-- On the other hand, if the thread's priority is boosted, there is no reason to be polite.
  2551             //-- On the other hand, if the thread's priority is boosted, there is no reason to be so polite.
  2544             if(!pSelf->IsPriorityBoosted())
  2552             if(!pSelf->IsPriorityBoosted())
  2545                 User::After(K1mSec); //-- User::After() granularity can be much coarser than 1ms
  2553                 {//-- User::After() granularity can be much coarser than 1ms, e.g. 1/64 Sec. This will add up to the scanning time
       
  2554                 User::After(K1mSec); 
       
  2555                 }
       
  2556             else
       
  2557                 {//-- use much less coarse granularity to allow this thread to be preempted even if its priority is boosted.
       
  2558                 User::AfterHighRes(128); 
       
  2559                 }
  2546 
  2560 
  2547             //-------------------------------------------
  2561             //-------------------------------------------
  2548             mediaPos += bytesToRead;
  2562             mediaPos += bytesToRead;
  2549             rem -= bytesToRead;
  2563             rem -= bytesToRead;
  2550         
  2564