seems to me...

channels are for language-handled concurrency which is able to then, 
transparently, be parallel, readers are a single threaded thing that mimics 
concurrency, they do it explicitly.

so you need to 'drive' the readers by calling them all in a loop, handling 
any none zero length, the channels can be 'selected' because the language 
handles calling the right piece of code as other, possible threaded code, 
drops something on a channels.

On Saturday, 26 January 2019 00:44:28 UTC, Roman Manz wrote:
>
> Hello Tarmigan,
>
> I am new to go and I find myself asking the same question.
> Did you come to a conclusion about this?
>
> Many thanks,
> Roman
>
> On Tuesday, March 8, 2011 at 9:02:14 PM UTC+1, Tarmigan wrote:
>>
>> On Mar 8, 11:40 am, Florian Weimer <f...@deneb.enyo.de> wrote: 
>> > > Even io.MultiReader doesn't do what I am interested in though because 
>> > > it reads all of the readers sequentially.  For this application, I 
>> > > want to read them simultaneously (think network io.Readers instead of 
>> > > file io.Readers). 
>> > 
>> > The io.Reader interface is geared towards streams of bytes, and it 
>> > will be difficult to interleave them with useful results.  What kinds 
>> > of data are you trying to process? 
>>
>> Agreed.  My data could not be interleaved. 
>>
>> For a bit more context, the similarities in the times I have needed 
>> this are when I have been muxing or demuxing a set of data streams (a 
>> server type application for example).  For example in one application 
>> data was read from a single io.ReadWriteCloser and sent on to several 
>> io.ReadWriters.  All of the io.ReadWriters could then send data back 
>> to the single io.ReadWriteCloser.  I could potentially have done this 
>> with a bunch of independent goroutines that each did an io.Copy or 
>> something, but because no one goroutine owns the single 
>> io.ReadWriteCloser that would pose problems with intermixed writing 
>> (same problem as you mentioned with the reading) and with error 
>> handling/closing/reconnecting. 
>>
>> To be clear, my program is working, but I have found myself using this 
>> same pattern a few times and I am wondering if a) there is a different 
>> way I should be doing it or b) if converting from an io.Reader to a 
>> set of channels would be useful to other people too. 
>>
>> Thanks, 
>> Tarmigan
>
>

-- 
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.

Reply via email to