shiny, windows, and goroutines

131 views
Skip to first unread message

SuperTXT Team

unread,
Oct 18, 2023, 6:55:26 AM10/18/23
to golan...@googlegroups.com
Hi All,

I'm experimenting with shiny, trying to develop a wire protocol for
it. I have some questions about the interfaces.

It seems from some of the examples in the documentation and some
tutorials that everything except perhaps sending custom window events
(to trigger updates to the UI) occur on a single event loop goroutine,
which is the same one that the driver's Main function runs in. This
isn't spelled out in the screen interfaces, so I wonder if this is
really a true constraint.

If this is true, then how does one handle multiple active windows? The
window.NextEvent() is blocking, and isn't a channel that permits
selecting on multiple windows at once.

Otherwise, if it's expected that in some scenarios, such as multiple
windows, that there will be more goroutines what sorts of permissible
goroutine configurations are allowed? Can I have a goroutine per
window, or can any goroutine access anything at any time?

Thanks!

Nigel Tao

unread,
Oct 18, 2023, 7:13:03 PM10/18/23
to SuperTXT Team, golan...@googlegroups.com
It's been a long time, so I can't remember all of the details, but I
think you can have goroutine per window. Grepping the
golang.org/x/exp/shiny/driver/*driver code for sync.Mutex gives
multiple hits.

You're right that the docs aren't helpful here. However, we were all
re-assigned from shiny (to working on other things) well before shiny
hit anything close to a "1.0 quality" milestone. And the initial focus
was on the single-window use case. For example, on mobile, you
couldn't even have multiple windows. All of the shiny/example programs
use a single window. I wouldn't be surprised if trying to use multiple
shiny windows doesn't work very well.
Reply all
Reply to author
Forward
0 new messages