优化连接管理和日志记录
This commit is contained in:
@@ -35,7 +35,7 @@ func ChanConnAccept(ctx context.Context, ls net.Listener) chan net.Conn {
|
||||
return connCh
|
||||
}
|
||||
|
||||
func ChanWgWait(ctx context.Context, wg *CountWaitGroup) chan struct{} {
|
||||
func ChanWgWait[T WaitGroup](ctx context.Context, wg T) chan struct{} {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
wg.Wait()
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type WaitGroup interface {
|
||||
Add(delta uint)
|
||||
Add(delta int)
|
||||
Done()
|
||||
Wait()
|
||||
}
|
||||
@@ -16,8 +16,8 @@ type CountWaitGroup struct {
|
||||
num atomic.Int64
|
||||
}
|
||||
|
||||
func (c *CountWaitGroup) Add(delta uint) {
|
||||
c.wg.Add(int(delta))
|
||||
func (c *CountWaitGroup) Add(delta int) {
|
||||
c.wg.Add(delta)
|
||||
c.num.Add(int64(delta))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user