pkg/channel/signal.go

24 lines
270 B
Go
Raw Permalink Normal View History

2023-09-18 15:51:20 +08:00
package channel
type signal struct{}
var def signal
type Signal chan signal
func NewSingle() Signal {
return make(Signal)
}
func NewBufferSingle(size int) Signal {
return make(Signal, size)
}
func (c Signal) Send() {
c <- def
}
func (c Signal) Read() {
<-c
}