From 2ae43be5258e1af300faa9aa5cdc7952adfda263 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 28 Mar 2020 00:54:42 +0100 Subject: [PATCH] Document functions safe to call from any goroutine --- downstream.go | 4 +++- upstream.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/downstream.go b/downstream.go index 76b7c0f..c97f5df 100644 --- a/downstream.go +++ b/downstream.go @@ -306,15 +306,17 @@ func (dc *downstreamConn) writeMessages() error { return nil } +// Close closes the connection. It is safe to call from any goroutine. func (dc *downstreamConn) Close() error { if dc.isClosed() { return fmt.Errorf("downstream connection already closed") } - close(dc.closed) return nil } +// SendMessage queues a new outgoing message. It is safe to call from any +// goroutine. func (dc *downstreamConn) SendMessage(msg *irc.Message) { dc.outgoing <- msg } diff --git a/upstream.go b/upstream.go index 2950da0..93489d3 100644 --- a/upstream.go +++ b/upstream.go @@ -145,6 +145,7 @@ func (uc *upstreamConn) isClosed() bool { } } +// Close closes the connection. It is safe to call from any goroutine. func (uc *upstreamConn) Close() error { if uc.isClosed() { return fmt.Errorf("upstream connection already closed") @@ -1391,6 +1392,8 @@ func (uc *upstreamConn) readMessages(ch chan<- event) error { return nil } +// SendMessage queues a new outgoing message. It is safe to call from any +// goroutine. func (uc *upstreamConn) SendMessage(msg *irc.Message) { uc.outgoing <- msg }