mirror of
https://github.com/gissleh/irc.git
synced 2026-10-19 05:32:53 +00:00
Renamed Client's EmitSafe to EmitNonBlocking to make it clearer what it's for.
This commit is contained in:
@@ -222,7 +222,7 @@ func (client *Client) Send(line string) error {
|
|||||||
|
|
||||||
_, err := conn.Write([]byte(line))
|
_, err := conn.Write([]byte(line))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.EmitSafe(NewErrorEvent("network", err.Error()))
|
client.EmitNonBlocking(NewErrorEvent("network", err.Error()))
|
||||||
client.Disconnect()
|
client.Disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,10 +265,10 @@ func (client *Client) Emit(event Event) context.Context {
|
|||||||
return event.ctx
|
return event.ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmitSafe is just like emit, but it will spin off a goroutine if the channel is full.
|
// EmitNonBlocking is just like emit, but it will spin off a goroutine if the channel is full.
|
||||||
// This lets it be called from other handlers without risking a deadlock. See Emit for
|
// This lets it be called from other handlers without ever blocking. See Emit for what the
|
||||||
// what the returned context is for.
|
// returned context is for.
|
||||||
func (client *Client) EmitSafe(event Event) context.Context {
|
func (client *Client) EmitNonBlocking(event Event) context.Context {
|
||||||
event.ctx, event.cancel = context.WithCancel(client.ctx)
|
event.ctx, event.cancel = context.WithCancel(client.ctx)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in New Issue
Block a user