Conversation
|
@KomiSans 感谢贡献,似乎改格式的太多了,我没有找到核心的改动。如果可以的话,改格式的单独出来做一个 PR 如何? |
| private bool _isDisposed; | ||
|
|
||
| private readonly object _locker = new object(); | ||
| private readonly object _locker = new(); |
There was a problem hiding this comment.
由于采用源代码形式分发,考虑到源代码兼容性,不打算采用此语法特性
| task = null; | ||
| while (_queue.Count > 0) | ||
| task = default; | ||
| while (_queue.Count is 0) |
| } | ||
|
|
||
| return false; | ||
| return default; |
| public void SetNotExecutable() | ||
| { | ||
| Executable = false; | ||
| Executable = default; |
| } | ||
| // 如果不是空 | ||
| // 那么设置任务完成 | ||
| _waitForInitializationTask?.SetResult(true); |
There was a problem hiding this comment.
原本的写法是表示空和非空都在处理逻辑内,而且也方便加上断点进行调试。这个逻辑不做简化
| // 根据 DoubleBufferTask 的设计,这个方法只有一个线程进入 | ||
| FirstCheckInitialized: // 标签:第一个判断初始化方法 | ||
| // 根据 DoubleBufferTask 的设计,这个方法只有一个线程进入 | ||
| FirstCheckInitialized: // 标签:第一个判断初始化方法 |
There was a problem hiding this comment.
这里用到部分 Goto 的方式,似乎对标签的缩进格式有所不同。我比较喜欢使用不缩进的方式,用来表示标签就是和其他代码不同
| { | ||
| await _waitForInitializationTask!.Task.ConfigureAwait(false); | ||
| } | ||
| else |
| } | ||
| if (runningTaskList.Count <= MaxRunningCount) return; | ||
|
|
||
| if (WaitForFreeTask?.Task.IsCompleted is false) return; |
There was a problem hiding this comment.
这里的空逻辑是有意义的哦,不要省略了哦,表示两个情况都在逻辑预期内,且方便加上断点支持调试
这里是特意如此写的,还请不要简化
| { | ||
| throw new InvalidOperationException("在指定 KeepLastReentrancyTask 的任务时,方法内不允许返回 null。请至少返回 Task.FromResult<object>(null)。"); | ||
| throw new InvalidOperationException( | ||
| "在指定 KeepLastReentrancyTask 的任务时,方法内不允许返回 null。请至少返回 Task.FromResult<object>(null)。"); |
| /// 在派生类中执行重入任务的时候,从此处获取需要执行的可重入异步任务。 | ||
| /// </summary> | ||
| protected Func<TParameter, Task<TReturn>> WorkingTask { get; } | ||
| private Func<TParameter, Task<TReturn>> WorkingTask { get; } |
|
没问题的 我这边再看下然后提出PR
lindexi ***@***.***> 于2022年10月20日周四 10:03写道:
… ***@***.**** requested changes on this pull request.
感谢贡献,似乎看起来有一点小问题,期望修改
—
Reply to this email directly, view it on GitHub
<#70 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANLYJZQGXFWVEHF7RCEIPITWECR6XANCNFSM6AAAAAARJUQU2I>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
感谢指正 |
| <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| <AssemblyName>dotnetCampus.AsyncWorkerCollection</AssemblyName> | ||
| <LangVersion>8</LangVersion> |
| CurrentList = AList; | ||
| return BList; | ||
| } | ||
| CurrentList = ReferenceEquals(CurrentList, AList) ? AList : BList; |
| /// </summary> | ||
| /// <returns></returns> | ||
| public async ValueTask WaitForFree() | ||
| private async ValueTask WaitForFree() |
| private readonly ConcurrentQueue<AwaitableTask> _queue = new ConcurrentQueue<AwaitableTask>(); | ||
| private readonly AsyncAutoResetEvent _autoResetEvent; | ||
|
|
||
| // ReSharper disable once RedundantDefaultMemberInitializer |
There was a problem hiding this comment.
@Komi-Thaw 只是让 Resharper 开心而已
这里明确给定 _autoCancelPreviousTask 的初始值为 false 的值,和默认 bool 行为相同,此时 Resharper 没有理解意图,毕竟执行逻辑是等价的,于是提示这个 false 可以删除。但是这里我期望是明确给定 false 初始值,以便在后续有期望更改为 true 的时候,可以看到,之前的设计就是明确要 false 值
|
|
No description provided.