mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-09 11:51:02 -05:00
30 lines
496 B
Go
30 lines
496 B
Go
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
|
|
}
|