Re: [go-nuts] Question regarding goroutines

2017-01-25 Thread Justin Israel
On Wed, Jan 25, 2017, 4:25 PM Matt Harden wrote: > Yes, a hang in one goroutine will spread to the rest of the goroutines, > because the loop in engine() is run while holding the lock on the map. If > it hangs in Write(), any other goroutine trying to run engine() would block > on m.Lock(). > Wh

Re: [go-nuts] Question regarding goroutines

2017-01-24 Thread Matt Harden
In your program, the central data structure is a map of connections, and chat messages are only kept in variables. I would flip that around, and have a data structure storing the messages that you are currently attempting to distribute to the chat members, and have a goroutine or two for each conne

Re: [go-nuts] Question regarding goroutines

2017-01-24 Thread Matt Harden
Yes, a hang in one goroutine will spread to the rest of the goroutines, because the loop in engine() is run while holding the lock on the map. If it hangs in Write(), any other goroutine trying to run engine() would block on m.Lock(). By the way, in main() you might as well just say server() inste