13 Star 0 Fork 26

src-openEuler/etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0011-backport-Fix-wait-time-docs-tests-to-indicate-trigger-deadline.patch 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/etcd.git
[email protected]:src-openeuler/etcd.git
src-openeuler
etcd
etcd
master

搜索帮助