3 ms·
Could you implement this with a linked list underneath to remove the max queue size?
by gravypod 10y ago
Could you implement this with a linked list underneath to remove the max queue size?
- Xeoncross 10y agoSo a mutex-protected list that feeds the queue?
- gravypod 10y agoOr just have each goroutine read from a shared channel. From what I understand they are thread safe (granted I'm not a go person) and then expose the channel ass the method for adding. So all of the threads just read from the channel and rather then adding to a queue you write to the gochannel they are all reading from.
- Xeoncross 10y agoMaybe I'm missing something, but that is how I'm doing it. The Queue struct has a 'Queue.Jobs chan string' that is the public method for adding to the "Queue" and then the go worker()'s read from that buffered channel. Basically, this simple Queue just adds some niceties around a buffered channel X number of go func() are reading from.
- gravypod 10y agoOk well then can you back it by a linked list? That way there is no size.