Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教关于CreateNewSegment #17

Open
egb2000 opened this issue Mar 29, 2019 · 0 comments
Open

请教关于CreateNewSegment #17

egb2000 opened this issue Mar 29, 2019 · 0 comments

Comments

@egb2000
Copy link

egb2000 commented Mar 29, 2019

您好,_buffers.Count > _segmentChunks / 2 是表达什么意思? 怎么觉得不需要这条过滤呢?

` private void CreateNewSegment(bool forceCreation)
{
if (!_allowedToCreateMemory)
throw new UnableToCreateMemoryException();

        lock (_creatingNewSegmentLock)
        {
            if (!forceCreation && _buffers.Count > _segmentChunks / 2)
                return;

            var bytes = new byte[_segmentSize];
            _segments.Add(bytes);
            for (int i = 0; i < _segmentChunks; i++)
            {
                var chunk = new ArraySegment<byte>(bytes, i * _chunkSize, _chunkSize);
                _buffers.Push(chunk);
            }
        }
    }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant