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

延时队列 DelayQueue 实现 #115

Merged
merged 1 commit into from
Nov 7, 2022
Merged

Conversation

flycash
Copy link
Contributor

@flycash flycash commented Nov 1, 2022

新版本:

  • 核心是实现了自己定义的 cond,它能够达成 await(time.Duration) 的效果,简化了代码,代价就是会创建额外的 channel

@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Merging #115 (cb55587) into dev (27357ee) will decrease coverage by 0.64%.
The diff coverage is 89.24%.

❗ Current head cb55587 differs from pull request most recent head 4e01073. Consider uploading reports for the commit 4e01073 to get more accurate results

@@            Coverage Diff             @@
##              dev     #115      +/-   ##
==========================================
- Coverage   95.42%   94.78%   -0.65%     
==========================================
  Files          28       29       +1     
  Lines        1269     1362      +93     
==========================================
+ Hits         1211     1291      +80     
- Misses         43       54      +11     
- Partials       15       17       +2     
Impacted Files Coverage Δ
queue/delay_queue.go 89.24% <89.24%> (ø)
pool/task_pool.go 98.11% <0.00%> (-0.95%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@flycash
Copy link
Contributor Author

flycash commented Nov 1, 2022

我觉得从可读性上来说,这个代码最直观也最简洁

@flycash
Copy link
Contributor Author

flycash commented Nov 1, 2022

还是有破绽=。=

queue/delay_queue.go Outdated Show resolved Hide resolved
@flycash
Copy link
Contributor Author

flycash commented Nov 2, 2022

思来想去,还是觉得没有办法在同时控制 ctx 超时的时候,保持代码简单。

@flycash flycash changed the title Delay queue v3 延时队列 DelayQueue 实现 Nov 4, 2022
@flycash flycash linked an issue Nov 4, 2022 that may be closed by this pull request
@flycash flycash merged commit 233fbf4 into ecodeclub:dev Nov 7, 2022
flycash added a commit that referenced this pull request Dec 6, 2022
* sqlx 加密列 key长度校验 (#102)

* sqlx 加密列 key长度校验

* sqlx 加密列 key长度校验 补单元测试

* 修改加密列key长度错误提示

* atomicx: 泛型封装 atomic.Value (#101)

* atomicx: 泛型封装 atomic.Value

* 添加 CHANGELOG

* syncx/atomicx: 增加 Swap 和 CAS 的泛型包装

* 添加 swap nil 的测试

* 添加更加多的 benchmark 测试,同时保证 NewValue 和 NewValueOf 的语义在 nil 上一致

* 优化单元测试

* queue: API 定义 (#109)

* queue: API 定义

* 补充 API 说明

* 实现优先级队列和并发安全优先级队列 (#110)

基于小顶堆和切片的实现

* queue: 延时队列 (#115)

* 延迟队列: 优化唤醒入队元素逻辑 (#117)

* 修改CHANGELOG链接;添加测试用例修复bug

Signed-off-by: longyue0521 <longyueli0521@gmail.com>

* 修改cond的SignalCh为signalCh;理清注释

Signed-off-by: longyue0521 <longyueli0521@gmail.com>

Signed-off-by: longyue0521 <longyueli0521@gmail.com>

* value: AnyValue 设计 (#120) (#121)

* value: AnyValue 设计 (#120)

* 修复ci检测问题

* 1.fix cr问题
2.add changelog对该pr的引用
3.add license 头部

* 1.修改ChangeLog,加入新特性描述
2.挪出value包,放在根目录
3.统一error格式打印

* 断言方式.Name改为.String

Co-authored-by: vividwei <vividwei@tencent.com>

* queue: 基于切片的并发阻塞队列和基于 CAS 的并发队列设计 (#119)

* queue:使用list包中的LinkedList实现并发阻塞链式队列 (#122)

* queue:增加链式并发阻塞队列

Co-authored-by: kangdan <ujn_kangdan@qq.com>
Co-authored-by: dan.kang <dan.kang@realai.ai>

* ConcurrentLinkBlockingQueue 改成ConcurrentLinkedBlockingQueue (#123)



* ConcurrentLinkBlockingQueue 改成ConcurrentLinkedBlockingQueue

* modify .CHANGELOG.md

* modify .CHANGELOG.md

Co-authored-by: kangdan <ujn_kangdan@qq.com>
Co-authored-by: dan.kang <dan.kang@realai.ai>

* queue: ConcurrentLinkedQueue增加超时控制逻辑 (#124)



Co-authored-by: kangdan <ujn_kangdan@qq.com>
Co-authored-by: dan.kang <dan.kang@realai.ai>

* queue: 添加例子

- 添加队列例子
- 去除 ConcurrentLinkedQueue 的超时机制

* queue: 添加例子 (#126)

Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Co-authored-by: hookokoko <648646891@qq.com>
Co-authored-by: Gevin <flyhigher139@gmail.com>
Co-authored-by: Longyue Li <longyueli0521@gmail.com>
Co-authored-by: 韦佳栋 <353470469@qq.com>
Co-authored-by: vividwei <vividwei@tencent.com>
Co-authored-by: kangdan666 <95063166+kangdan6@users.noreply.github.com>
Co-authored-by: kangdan <ujn_kangdan@qq.com>
Co-authored-by: dan.kang <dan.kang@realai.ai>
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

Successfully merging this pull request may close these issues.

queue: 基于时间的线程安全优先级队列
2 participants