FAQ
Close the file in those cases. That will unblock the reading goroutine.

On Mon Oct 27 2014 at 2:21:43 PM Nick Patavalis wrote:


On Monday, October 27, 2014 5:09:30 PM UTC+2, Ian Lance Taylor wrote:

On Sun, Oct 26, 2014 at 11:12 PM, Nick Patavalis
wrote:
On Monday, October 27, 2014 5:35:23 AM UTC+2, Ian Lance Taylor wrote:


I wouldn't worry about using select. Instead have a goroutine that
does blocking reads and writes the data to a channel. Then other
goroutines can handle the timeout using a Go select statement.
Yes, but when the timeout is detected you need to, somehow, notify the
"reading" goroutine (which will probably be blocked inside read(2)) to
abort.
Why?

Hmmm.... So what you mean is that, once an FD is opened, you start a
goroutine reading from it and writing data to a channel, and leave it there
running.... forever. Whenever you want to read from the FD you actually
read from the channel. Yes, it could work.

Eventually, you will, though, have to stop this goroutine (somehow) even
if it is when you no longer need the FD (i.e. when it's time to close it),
and again, you have to do it "carefully"---for the reasons described above.

/npat

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 28 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 26, '14 at 9:10a
activeOct 27, '14 at 7:01p
posts28
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase