public LineReader(IMultiStreamSource files, int batchSize, int bufSize, bool hasHeader, long limit, int cref) { // Note that files is allowed to be empty. Contracts.AssertValue(files); Contracts.Assert(files.Count >= 0); Contracts.Assert(batchSize >= 2); Contracts.Assert(bufSize > 0); Contracts.Assert(limit >= 0); Contracts.Assert(cref > 0); _limit = limit; _hasHeader = hasHeader; _batchSize = batchSize; _files = files; _cref = cref; _queue = new BlockingQueue <LineBatch>(bufSize); _thdRead = Utils.RunOnBackgroundThread(ThreadProc); }
public void Release() { int n = Interlocked.Decrement(ref _cref); Contracts.Assert(n >= 0); if (n != 0) { return; } if (_thdRead != null) { _abort = true; _thdRead.Wait(); _thdRead = null; } if (_queue != null) { _queue.Dispose(); _queue = null; } }