private bool ReadChunk() { var alive = false; for (var i = 0; i < heads.Count; i++) { FR2_Head h = heads[i]; if (h.isDead) { Debug.LogWarning("Should never be here : " + h.chunkList[0].file); continue; } nScaned++; alive = true; h.ReadChunk(); h.CompareChunk(heads); break; } //if (!alive) return false; //alive = false; //for (var i = 0; i < heads.Count; i++) //{ // var h = heads[i]; // if (h.isDead) continue; // h.CompareChunk(heads); // alive |= !h.isDead; //} return(alive); }
private void ReadChunkAsync() { bool alive = ReadChunk(); HashChunksNotComplete.RemoveWhere(x => x.stream == null || !x.stream.CanRead); if (cacheList.Count > 0 && checkCompleteAllCurFile()) //complete all chunk { int numCall = FR2_Cache.Api.priority; // - 2; if (numCall <= 0) { numCall = 1; } for (var i = 0; i < numCall; i++) { if (cacheList.Count <= 0) { break; } AddHead(cacheList[cacheList.Count - 1]); cacheList.RemoveAt(cacheList.Count - 1); } } var update = false; for (int i = heads.Count - 1; i >= 0; i--) { FR2_Head h = heads[i]; if (h.isDead) { h.CloseChunk(); heads.RemoveAt(i); if (h.chunkList.Count > 1) { update = true; deads.Add(h); } } } if (update) { Trigger(OnCompareUpdate); } if (!alive && cacheList.Count <= 0 && checkCompleteAllCurFile() ) //&& cacheList.Count <= 0 complete all chunk and cache list empty { foreach (FR2_Chunk item in HashChunksNotComplete) { if (item.stream != null && item.stream.CanRead) { item.stream.Close(); item.stream = null; } } HashChunksNotComplete.Clear(); // Debug.Log("complete "); nScaned = nChunks; EditorApplication.update -= ReadChunkAsync; Trigger(OnCompareComplete); } }