Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 6m27s
feat: 添加版本和构建时间变量 fix: 修正短信队列类型注释错误 style: 清理未使用的代码和测试文件 docs: 更新安装文档中的下载链接 chore: 迁移数据库脚本添加日志和订阅配置
33 lines
638 B
Go
33 lines
638 B
Go
package syncx
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/perfect-panel/server/pkg/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
|
|
}
|