public bool TryDequeue(out CompressionBlock block) { bool result = false; lock (_lock) { result = LockedTryDequeue(out block); Monitor.Pulse(_lock); } return(result); }
protected override void LockedEnqeue(CompressionBlock block) { while (_queue.Count >= Capacity) { if (IsClosed) { return; } Monitor.Wait(_lock); } _queue.Enqueue(block); Monitor.Pulse(_lock); }
protected override bool LockedTryDequeue(out CompressionBlock block) { block = null; while (_queue.Count == 0) { if (IsClosed) { return(false); } Monitor.Wait(_lock); } block = _queue.Dequeue(); return(true); }
protected override void LockedEnqeue(CompressionBlock block) { while (_queue.Count >= Capacity || _processedBlocks != block.Id) { if (IsClosed) { return; } Monitor.Wait(_lock); } _queue.Enqueue(block); _processedBlocks++; Monitor.PulseAll(_lock); }
protected abstract bool LockedTryDequeue(out CompressionBlock block);
protected abstract void LockedEnqeue(CompressionBlock block);
public void Enqueue(CompressionBlock block) { lock (_lock) LockedEnqeue(block); }