thanks brian...I have looked at sync / channels but I think the
simplicity of mutex should work fine for me.

On Sat, 12 Sep 2020 at 18:13, Brian Candler <b.cand...@pobox.com> wrote:
>
> On Saturday, 12 September 2020 17:04:19 UTC+1, mb0 wrote:
>>
>> a global map is the way to go, however writing an reading the map from 
>> multiple go routines will fail (in your case different handle calls for 
>> connections) because the map data structure is not safe for concurrent use 
>> and must be coordinated. the way it is usually solved is by adding another 
>> sync.Mutex (mutually exclusive) variable to ensure only one go routine at a 
>> has access to the map.
>
>
> Another very common pattern is to have a separate goroutine for each 
> connection, and then the goroutines communicate using channels.
>
> --
> You received this message because you are subscribed to a topic in the Google 
> Groups "golang-nuts" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/golang-nuts/qsMfKWZ8HgI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/1cc5595e-d2ef-4dda-ab27-ce2052752393o%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOp5WB5M7md8CvCM_iZXpEBUuBZMMUni3nxRoP%2BMn%2BAJ3n1e%2BQ%40mail.gmail.com.

Reply via email to