#How to block until length of array != 0?

5 messages · Page 1 of 1 (latest)

indigo pendant
#

@loud matrix how is the array updated ?
It's obviously not gonna magically get shorter
Is an other goroutine doing something to it ?

loud matrix
#

yes, the access to the array is guarded by locks, and as you already guessed another goroutine takes the lock, appends to the array and releases the lock

#

let's say i can also put len(arr) in a function which takes the lock, checks len, releases the lock, and returns the length

#

maybe after appending in the other goroutine i should write to a channel that loopedFunction listens on?

indigo pendant