mirror of https://github.com/v2ray/v2ray-core
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.
30 lines
496 B
30 lines
496 B
9 years ago
|
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
|
||
|
}
|