1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-07 13:54:27 -04:00
v2fly/common/signal/close.go

30 lines
496 B
Go
Raw Normal View History

2016-04-25 12:39:30 -04:00
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
}