-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pool: TaskPool 实现 #50 TaskPool管理有限状态机,TaskExecutor负责启动任务,优雅关闭,强制退出等操作 Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 修复ShutdownNow data race问题 Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 处理注释等问题 Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 省略submitTask接收者名称 * 修改CHANGELOG.md * 修复因使用go1.19导致的atomic.Int32类型为定义问题 处理Task.Run返回的error,fmt.Println可能导致并发问题 Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 重构TaskPool并整理测试 Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 修改.CHANGELOG.md Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 1.将time.After替换为time.Sleep 2.将Task运行时抛出的panic接住并封装为error返回 * 1.显示检查queue是否被关闭 2.处理Start/Shutdown/ShutdownNow()重复调用问题 3.Submit方法中只检验task==nil的情况 * 1. 因为调整为重复调用后直接报错,重构ShutdownNow()并去掉submittedTasks和Sync.RWMutex 2. 重构Shutdown()使用sync.WaitGroup替代用time.Sleep来检测b.num==0 3. 将StartTasks重命名为schedulingTasks * 添加注释修改代码提高可读性 Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 1.task_pool.go 修改task的声明方式,显示指定其容量 2.task_pool_test.go 重新组织测试使其更具可读性,清理魔数显示表明其意图等 Signed-off-by: longyue0521 <longyueli0521@gmail.com> * 改为更宽泛的断言 * 修改测试用例 Signed-off-by: longyue0521 <longyueli0521@gmail.com> Signed-off-by: Longyue Li <longyueli0521@gmail.com>
- Loading branch information
1 parent
4076fdc
commit 07ae8de
Showing
3 changed files
with
729 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.