Just as a follow up for anyone else - in the end I used two simple stacks for available and active lists of workers and simply popped a worker of the available stack when a url came in, assigned it to the worker and then pushed it to the active stack. Job done!
On Thursday, December 1, 2016 at 9:07:42 AM UTC, omarsharif...@gmail.com wrote: > > Yeah I kinda figured I was coming to this wrong way - my tired brain had > an unterminated loop. Thanks for the pointers! (all puns intended) > > On Wednesday, November 30, 2016 at 5:08:06 PM UTC, omarsharif...@gmail.com > wrote: >> >> Hi, I'm having a bit of a slow day... I'm trying to synchronise two reads >> from two channels and can't get my fuzzy head round the problem. >> >> I have a channel containing urls (which will be feed periodically by a >> named pipe by another program) and I have a cannel which consists of a pool >> of available workers. I'd like to synchronise these and put a worker into a >> third channel for active workers if there is a url in the channel and if >> there is an available worker. >> >> Ideally I'd be able to do something like: >> >> go func(urlChan <-chan *url.URL, availableWorkerChan <-chan *worker, >> activeWorkerChan chan<- *worker){ >> for { >> select{ >> case w := <-availableWorkerChan && w.Url = <-urlChan: >> activeWorkersChan <- w >> } >> } >> }(a, b, c) >> >> But obviously thats not right! >> >> Can anyone offer my tired brain a clue? >> >> Cheers! >> Ben >> > -- 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. For more options, visit https://groups.google.com/d/optout.