Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
* Robert Engels [191112 13:44]: > Sorry, at work so I need to use the 'web mail' interface and it > doesn't appear to be including them when I reply. Understood. I'll just try to follow the threading as best as I can. ...Marvin -- You received this message because you are subscribed to the Go

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Robert Engels
ang/go/issues/5045 >> >> -Original Message- >> >From: Marvin Renich >> >Sent: Nov 12, 2019 11:30 AM >> >To: golang-nuts >> >Subject: Re: [go-nuts] What is the correct way to access/modify slice >> >elements concurrently >>

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
; >Sent: Nov 12, 2019 11:30 AM > >To: golang-nuts > >Subject: Re: [go-nuts] What is the correct way to access/modify slice > >elements concurrently > > > >[I almost missed this post because you did not reply to the thread.] > > > >* Robert Engels [191

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Robert Engels
This is not the issue I am referring to, I am referring to https://github.com/golang/go/issues/5045 -Original Message- >From: Marvin Renich >Sent: Nov 12, 2019 11:30 AM >To: golang-nuts >Subject: Re: [go-nuts] What is the correct way to access/modify slice elements &

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-12 Thread Marvin Renich
[I almost missed this post because you did not reply to the thread.] * Robert Engels [191108 11:41]: > See https://github.com/golang/go/issues/10958 for using atomics in > tight/busy-wait loops. This doesn't have anything to do with atomics. Atomic operations are just one of many, many things

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread Robert Engels
-Original Message- >From: burak serdar >Sent: Nov 8, 2019 9:19 AM >To: golang-nuts >Subject: Re: [go-nuts] What is the correct way to access/modify slice elements >concurrently > >On Fri, Nov 8, 2019 at 7:55 AM Marvin Renich wrote: >> >> * bur

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread burak serdar
On Fri, Nov 8, 2019 at 7:55 AM Marvin Renich wrote: > > * burak serdar [191108 08:42]: > > I was thinking about this. In general, it should be safe to replace > > > > Lock() > > read/write one value > > Unlock() > > > > with > > > > AtomicRead/Write > > > > Is that correct? The go memory model do

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread Marvin Renich
* burak serdar [191108 08:42]: > I was thinking about this. In general, it should be safe to replace > > Lock() > read/write one value > Unlock() > > with > > AtomicRead/Write > > Is that correct? The go memory model does not say anything about this. Yes. While others have argued that the GM

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread Robert Engels
Almost always, but it is very difficult as most times you are not really working with a single value (there are implied dependencies). These sort of solutions fall under “lock free” structures/algorithms - and they are fascinating to learn about. > On Nov 8, 2019, at 7:42 AM, burak serdar wro

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread burak serdar
On Fri, Nov 8, 2019 at 6:25 AM Marvin Renich wrote: > > * Kasun Vithanage [191107 23:47]: > > type Foo struct { > > Alive bool > > } > > > > type Bar struct { > > Foos []*Foo > > } > > > > func (b *Bar) CheckFoosAlive() { > > for i := 0; i < len(b.Foos); i++ { > > if b.Foos[i].Alive {

Re: [go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread Marvin Renich
* Kasun Vithanage [191107 23:47]: > type Foo struct { > Alive bool > } > > type Bar struct { > Foos []*Foo > } > > func (b *Bar) CheckFoosAlive() { > for i := 0; i < len(b.Foos); i++ { > if b.Foos[i].Alive { > fmt.Println("Alive") > } > } > } > > func (b* Bar) MarkFooStat