aboutsummaryrefslogtreecommitdiffstats
path: root/event/subscription.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-26 18:57:31 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-03 19:37:49 +0800
commit1bed9b3fea9939581b03cae9d6b4984ced456748 (patch)
treeb1cb7cbd1acb6cc9b07c8931a24d89f5e74c89de /event/subscription.go
parenta2b4abd89adf0404b43fcd19766bac37009032a5 (diff)
downloadgo-tangerine-1bed9b3fea9939581b03cae9d6b4984ced456748.tar.gz
go-tangerine-1bed9b3fea9939581b03cae9d6b4984ced456748.tar.zst
go-tangerine-1bed9b3fea9939581b03cae9d6b4984ced456748.zip
event: address review issues (multiple commits)
event: address Feed review issues event: clarify role of NewSubscription function event: more Feed review fixes * take sendLock after dropping f.mu * add constant for number of special cases event: fix subscribing/unsubscribing while Send is blocked
Diffstat (limited to 'event/subscription.go')
-rw-r--r--event/subscription.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/event/subscription.go b/event/subscription.go
index 7f2619b2d..83bd21213 100644
--- a/event/subscription.go
+++ b/event/subscription.go
@@ -43,14 +43,14 @@ type Subscription interface {
Unsubscribe() // cancels sending of events, closing the error channel
}
-// NewSubscription runs fn as a subscription in a new goroutine. The channel given to fn
-// is closed when Unsubscribe is called. If fn returns an error, it is sent on the
-// subscription's error channel.
-func NewSubscription(fn func(<-chan struct{}) error) Subscription {
+// NewSubscription runs a producer function as a subscription in a new goroutine. The
+// channel given to the producer is closed when Unsubscribe is called. If fn returns an
+// error, it is sent on the subscription's error channel.
+func NewSubscription(producer func(<-chan struct{}) error) Subscription {
s := &funcSub{unsub: make(chan struct{}), err: make(chan error, 1)}
go func() {
defer close(s.err)
- err := fn(s.unsub)
+ err := producer(s.unsub)
s.mu.Lock()
defer s.mu.Unlock()
if !s.unsubscribed {