コード例 #1
0
ファイル: ChunkWriteStream.cs プロジェクト: oleg-st/DevSync
            private void DoWork()
            {
                // lock chunk
                lock (_chunkBytes)
                {
                    if (!_needToFlush)
                    {
                        return;
                    }

                    try
                    {
                        if (_compression != null && _chunkLength >= CompressionThreshold &&
                            TryCompress(out var written))
                        {
                            WriteChunk(_chunkCompressedBytes, written, true);
                        }
                        else
                        {
                            WriteChunk(_chunkBytes, _chunkLength, false);
                        }
                    }
                    catch (Exception exception)
                    {
                        _flushException = exception;
                    }

                    _flushStopwatch.Start();
                    _needToFlush = false;
                }
                UpdateHasWork();
            }
コード例 #2
0
            public void Flush()
            {
                if (_totalCount <= 0)
                {
                    return;
                }

                _logger.Log(_totalCount == 1
                    ? $"Sent {_lastChange} in {(int)_timeSpan.TotalMilliseconds} ms"
                    : $"Sent {_totalCount} changes, {PrettySize(_totalSize)} in {(int)_timeSpan.TotalMilliseconds} ms");

                _lastChange = "";
                _totalCount = 0;
                _totalSize  = 0;
                _timeSpan   = TimeSpan.Zero;
                _stopwatch.Start();
            }