示例#1
0
  /**
   * Change the size of the cache. Cache will be cleaned immediately.
   */
  void DataTileCache::SetSize(size_t cacheSize)
  {
    bool cleanupCache=cacheSize<this->cacheSize;

    this->cacheSize=cacheSize;

    if (cleanupCache) {
      CleanupCache();
    }
  }
// -----------------------------------------------------------------------------
// Clean up all caches
// -----------------------------------------------------------------------------
//
TBool CGlxGarbageCollector::CleanupCaches(TInt aCount)
    {
    TRACER( "CGlxGarbageCollector::CleanupCaches" );

    TInt remainingScanCount = 0;

    // set the maximum number of items to scan during this call
    // Count is Needed for Flushing Direct
    remainingScanCount = aCount*KMaxScannedMediaCountPerPeriodicCallback;
    
    // Iterate through all cache until scanned enough items (remainingScanCount)
    // (unlikely to have many caches, so ok to call RPointerArray::Count() on 
    // each iteration)
    while ( iScanningPosition.iCurrentCacheIndex < iCaches.Count() )
        {
        // clean up current cache
        remainingScanCount = CleanupCache( 
            *iCaches[iScanningPosition.iCurrentCacheIndex], remainingScanCount );
            
        // exit the loop if reached full scan count, since the above loop might
        // have reached the end of the cache. (so don't increment the current
        // cache index)
        if ( 0 == remainingScanCount )
            {
            break;
            }
        
        // set indexes to the beginning of the next cache
        iScanningPosition.iCurrentCacheIndex++;
        iScanningPosition.iNextMediaIndexToCleanup = 0; 
        }
    
    // determine if there is anything more to clean up
    TBool reachedEndOfAllCaches = 
        ( iScanningPosition.iCurrentCacheIndex == iCaches.Count() );
    return reachedEndOfAllCaches;
    }
D3DDisplayManager::~D3DDisplayManager()
{
	DeviceReset();
	CleanupCache();
}
示例#4
0
bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state, bool fJustCheck)
{
    AssertLockHeld(cs_main);

    const auto& consensusParams = Params().GetConsensus();
    bool fDIP0003Active = pindex->nHeight >= consensusParams.DIP0003Height;
    if (!fDIP0003Active) {
        return true;
    }

    CDeterministicMNList oldList, newList;
    CDeterministicMNListDiff diff;

    int nHeight = pindex->nHeight;

    {
        LOCK(cs);

        if (!BuildNewListFromBlock(block, pindex->pprev, _state, newList, true)) {
            return false;
        }

        if (fJustCheck) {
            return true;
        }

        if (newList.GetHeight() == -1) {
            newList.SetHeight(nHeight);
        }

        newList.SetBlockHash(block.GetHash());

        oldList = GetListForBlock(pindex->pprev->GetBlockHash());
        diff = oldList.BuildDiff(newList);

        evoDb.Write(std::make_pair(DB_LIST_DIFF, diff.blockHash), diff);
        if ((nHeight % SNAPSHOT_LIST_PERIOD) == 0 || oldList.GetHeight() == -1) {
            evoDb.Write(std::make_pair(DB_LIST_SNAPSHOT, diff.blockHash), newList);
            LogPrintf("CDeterministicMNManager::%s -- Wrote snapshot. nHeight=%d, mapCurMNs.allMNsCount=%d\n",
                __func__, nHeight, newList.GetAllMNsCount());
        }
    }

    // Don't hold cs while calling signals
    if (diff.HasChanges()) {
        GetMainSignals().NotifyMasternodeListChanged(false, oldList, diff);
        uiInterface.NotifyMasternodeListChanged();
    }

    if (nHeight == consensusParams.DIP0003EnforcementHeight) {
        if (!consensusParams.DIP0003EnforcementHash.IsNull() && consensusParams.DIP0003EnforcementHash != pindex->GetBlockHash()) {
            LogPrintf("CDeterministicMNManager::%s -- DIP3 enforcement block has wrong hash: hash=%s, expected=%s, nHeight=%d\n", __func__,
                    pindex->GetBlockHash().ToString(), consensusParams.DIP0003EnforcementHash.ToString(), nHeight);
            return _state.DoS(100, false, REJECT_INVALID, "bad-dip3-enf-block");
        }
        LogPrintf("CDeterministicMNManager::%s -- DIP3 is enforced now. nHeight=%d\n", __func__, nHeight);
    }

    LOCK(cs);
    CleanupCache(nHeight);

    return true;
}