You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This works pretty well, and I use it in my application, except when using a multi-producer setup. ChannelEvents closes the channel when quit is closed, and may cause a “send on closed channel” panic on other event producers. This doesn't happen often, and if it does, it's only during shutdown, so it's not a big issue.
In Go, typically sync.WaitGroup is used in such cases.
In this case, each event producer would call wg.Done() instead of closing the channel or simply returning when quit is closed. Another goroutine would wait and close events when all event producers finish.
To do this in tcell would mean adding another method to Screen since it is incompatible with the existing one.
I thought another option would be exporting the channel so that the user can implement ChannelEvents in whatever way they want (I vaguely remember exporting events channel mentioned in another issue, but I couldn't find it).
I guess a workaround would be to wrap the existing ChannelEvents with another channel in the middle.
In Go, typically sync.WaitGroup is used in such cases.
It looks like it still sometimes panics, even with this. I am using context.WithCancel and ctx.Done and cancel() instead of quit chan struct{}, maybe that is an issue.
This is not a bug. It's a discussion and maybe a feature request.
I contributed the
ChannelEvents
method that redirects events from the internal channel to a user-created channel. #465This works pretty well, and I use it in my application, except when using a multi-producer setup.
ChannelEvents
closes the channel whenquit
is closed, and may cause a “send on closed channel” panic on other event producers. This doesn't happen often, and if it does, it's only during shutdown, so it's not a big issue.In Go, typically
sync.WaitGroup
is used in such cases.In this case, each event producer would call
wg.Done()
instead of closing the channel or simply returning whenquit
is closed. Another goroutine would wait and closeevents
when all event producers finish.To do this in tcell would mean adding another method to
Screen
since it is incompatible with the existing one.I thought another option would be exporting the channel so that the user can implement ChannelEvents in whatever way they want (I vaguely remember exporting events channel mentioned in another issue, but I couldn't find it).
I guess a workaround would be to wrap the existing
ChannelEvents
with another channel in the middle.The text was updated successfully, but these errors were encountered: