1 Star 0 Fork 0

Stefan/go-zero

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
donechan.go 636 Bytes
一键复制 编辑 原始数据 按行查看 历史
Stefan 提交于 2025-06-11 18:20 +08:00 . fix import package
package syncx
import (
"sync"
"gitee.com/emmm_admin/go-zero/core/lang"
)
// A DoneChan is used as a channel that can be closed multiple times and wait for done.
type DoneChan struct {
done chan lang.PlaceholderType
once sync.Once
}
// NewDoneChan returns a DoneChan.
func NewDoneChan() *DoneChan {
return &DoneChan{
done: make(chan lang.PlaceholderType),
}
}
// Close closes dc, it's safe to close more than once.
func (dc *DoneChan) Close() {
dc.once.Do(func() {
close(dc.done)
})
}
// Done returns a channel that can be notified on dc closed.
func (dc *DoneChan) Done() chan lang.PlaceholderType {
return dc.done
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/stefan886/go-zero.git
git@gitee.com:stefan886/go-zero.git
stefan886
go-zero
go-zero
45236c288c2b

搜索帮助