Skip to content

Commit c14e1c9

Browse files
committed
Let Signal and Eavesdrop accept send-only channels
1 parent 3ec96e9 commit c14e1c9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

conn.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ type Conn struct {
5454
closed bool
5555
outLck sync.RWMutex
5656

57-
signals []chan *Signal
57+
signals []chan<- *Signal
5858
signalsLck sync.Mutex
5959

60-
eavesdropped chan *Message
60+
eavesdropped chan<- *Message
6161
eavesdroppedLck sync.Mutex
6262
}
6363

@@ -203,12 +203,12 @@ func (conn *Conn) Close() error {
203203
// sent to the appropiate channels and method calls will not be handled. If nil
204204
// is passed, the normal behaviour is restored.
205205
//
206-
// The caller has to make sure that c is sufficiently buffered;
207-
// if a message arrives when a write to c is not possible, the message is
206+
// The caller has to make sure that ch is sufficiently buffered;
207+
// if a message arrives when a write to ch is not possible, the message is
208208
// discarded.
209-
func (conn *Conn) Eavesdrop(c chan *Message) {
209+
func (conn *Conn) Eavesdrop(ch chan<- *Message) {
210210
conn.eavesdroppedLck.Lock()
211-
conn.eavesdropped = c
211+
conn.eavesdropped = ch
212212
conn.eavesdroppedLck.Unlock()
213213
}
214214

@@ -486,10 +486,10 @@ func (conn *Conn) serials() {
486486
// channel that already is registered will remove it from the list of the
487487
// registered channels.
488488
//
489-
// Thess channels are "overwritten" by Eavesdrop; i.e., if there currently is a
489+
// These channels are "overwritten" by Eavesdrop; i.e., if there currently is a
490490
// channel for eavesdropped messages, this channel receives all signals, and
491491
// none of the channels passed to Signal will receive any signals.
492-
func (conn *Conn) Signal(ch chan *Signal) {
492+
func (conn *Conn) Signal(ch chan<- *Signal) {
493493
conn.signalsLck.Lock()
494494
conn.signals = append(conn.signals, ch)
495495
conn.signalsLck.Unlock()

0 commit comments

Comments
 (0)