Document functions safe to call from any goroutine

This commit is contained in:
Simon Ser 2020-03-28 00:54:42 +01:00
parent 1c3da31f2e
commit 2ae43be525
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 6 additions and 1 deletions

View File

@ -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
}

View File

@ -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
}