代码拉取完成,页面将自动刷新
From 5f782c350f84f3f0e1386cb2d539a509a41336f7 Mon Sep 17 00:00:00 2001
From: redwrasse <[email protected]>
Date: Sat, 27 Jul 2024 21:41:40 +0000
Subject: [PATCH] fix wait_time docs, tests for trigger deadline greater than
or equal to wait deadline
Signed-off-by: redwrasse <[email protected]>
---
pkg/wait/wait_time.go | 4 ++--
pkg/wait/wait_time_test.go | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/pkg/wait/wait_time.go b/pkg/wait/wait_time.go
index 297e48a..1317889 100644
--- a/pkg/wait/wait_time.go
+++ b/pkg/wait/wait_time.go
@@ -19,9 +19,9 @@ import "sync"
type WaitTime interface {
// Wait returns a chan that waits on the given logical deadline.
// The chan will be triggered when Trigger is called with a
- // deadline that is later than the one it is waiting for.
+ // deadline that is later than or equal to the one it is waiting for.
Wait(deadline uint64) <-chan struct{}
- // Trigger triggers all the waiting chans with an earlier logical deadline.
+ // Trigger triggers all the waiting chans with an equal or earlier logical deadline.
Trigger(deadline uint64)
}
diff --git a/pkg/wait/wait_time_test.go b/pkg/wait/wait_time_test.go
index 26164c4..2047558 100644
--- a/pkg/wait/wait_time_test.go
+++ b/pkg/wait/wait_time_test.go
@@ -54,10 +54,10 @@ func TestWaitTime(t *testing.T) {
func TestWaitTestStress(t *testing.T) {
chs := make([]<-chan struct{}, 0)
wt := NewTimeList()
- for i := 0; i < 10000; i++ {
+ for i := 0; i <= 10000; i++ {
chs = append(chs, wt.Wait(uint64(i)))
}
- wt.Trigger(10000 + 1)
+ wt.Trigger(10000)
for _, ch := range chs {
select {
@@ -78,9 +78,9 @@ func BenchmarkWaitTime(b *testing.B) {
func BenchmarkTriggerAnd10KWaitTime(b *testing.B) {
for i := 0; i < b.N; i++ {
wt := NewTimeList()
- for j := 0; j < 10000; j++ {
+ for j := 0; j <= 10000; j++ {
wt.Wait(uint64(j))
}
- wt.Trigger(10000 + 1)
+ wt.Trigger(10000)
}
}
--
2.9.3.windows.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。