mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-05 15:33:11 +00:00
extract subscription to separate file
This commit is contained in:
parent
9b7b942ac4
commit
547be3c951
26
waku/v2/node/subscription.go
Normal file
26
waku/v2/node/subscription.go
Normal file
@ -0,0 +1,26 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/status-im/go-waku/waku/common"
|
||||
)
|
||||
|
||||
type Subscription struct {
|
||||
C chan *common.Envelope
|
||||
closed bool
|
||||
mutex sync.Mutex
|
||||
quit chan struct{}
|
||||
}
|
||||
|
||||
func (subs *Subscription) Unsubscribe() {
|
||||
if !subs.closed {
|
||||
close(subs.quit)
|
||||
}
|
||||
}
|
||||
|
||||
func (subs *Subscription) IsClosed() bool {
|
||||
subs.mutex.Lock()
|
||||
defer subs.mutex.Unlock()
|
||||
return subs.closed
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user