mirror of
https://github.com/libp2p/go-eventbus.git
synced 2025-03-25 12:10:06 +08:00
Return error when closing already closed emitter
This commit is contained in:
parent
b1629519a0
commit
217da8e826
2
basic.go
2
basic.go
@ -38,7 +38,7 @@ func (e *emitter) Emit(evt interface{}) error {
|
||||
|
||||
func (e *emitter) Close() error {
|
||||
if !atomic.CompareAndSwapInt32(&e.closed, 0, 1) {
|
||||
panic("closed an emitter more than once")
|
||||
return fmt.Errorf("closed an emitter more than once")
|
||||
}
|
||||
if atomic.AddInt32(&e.n.nEmitters, -1) == 0 {
|
||||
e.dropper(e.typ)
|
||||
|
Loading…
Reference in New Issue
Block a user