public void Flush (TorrentFile file) { CachedBlocks.RemoveAll (delegate (CachedBlock b) { if (b.File != file) return false; Interlocked.Add (ref cacheUsed, -b.Count); Writer.Write (b.File, b.Offset, b.Buffer, 0, b.Count); ClientEngine.BufferPool.Return (b.Buffer); return true; }); }
public void Flush(TorrentFile file) { CachedBlocks.RemoveAll(delegate(CachedBlock b) { if (b.File != file) { return(false); } Interlocked.Add(ref cacheUsed, -b.Count); Writer.Write(b.File, b.Offset, b.Buffer, 0, b.Count); ClientEngine.BufferManager.FreeBuffer(b.Buffer); return(true); }); }
public async ReusableTask FlushAsync(ITorrentFileInfo file) { foreach (var block in CachedBlocks) { if (block.File != file) { continue; } Interlocked.Add(ref cacheUsed, -block.Count); using (block.BufferReleaser) await Writer.WriteAsync(block.File, block.Offset, block.Buffer, 0, block.Count); } CachedBlocks.RemoveAll(b => b.File == file); }
public void Flush(TorrentFile file) { CachedBlocks.RemoveAll(delegate(CachedBlock b) { if (b.File != file) { return(false); } Interlocked.Add(ref cacheUsed, -b.Count); using (b.BufferReleaser) Writer.Write(b.File, b.Offset, b.Buffer, 0, b.Count); return(true); }); }