You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/common/signal/close.go

30 lines
496 B

package signal
type CancelSignal struct {
cancel chan struct{}
done chan struct{}
}
func NewCloseSignal() *CancelSignal {
return &CancelSignal{
cancel: make(chan struct{}),
done: make(chan struct{}),
}
}
func (this *CancelSignal) Cancel() {
close(this.cancel)
}
func (this *CancelSignal) WaitForCancel() <-chan struct{} {
return this.cancel
}
func (this *CancelSignal) Done() {
close(this.done)
}
func (this *CancelSignal) WaitForDone() <-chan struct{} {
return this.done
}