The obvious approach is to use a future or other thread as an intermediary
between the blocking I/O read and a channel, then use !< on the channel in
a go; something like:

(go
  (let [c (chan)]
    (future (>!! c (my-blocking-io-read some-stream)))
    (let [thingy (!< c)
      (do-something-with thingy))))

The channel can then be used in alts! and what-not as well, if you want to
react to any of several possible "next things", only one of which is the
I/O read completing and returning a value.

This *does* suggest making a small async.io library that provides a
nonblocking read operation that returns a channel, and maybe other related
facilities, such as a line-chan that pops line after line from the input
I/O source when read from, byte-chan (for binary files), edn-chan (top
level edn forms read from input), etc.



On Sat, Jul 6, 2013 at 3:23 PM, dennis zhuang <killme2...@gmail.com> wrote:

> It's so cool,great job!
> But i don't find any way to do io blocking operations such as socket.read
> in 'go'.
> Is there a roadmap to make alts! working with java NIO selector that waits
> on socket channels?
> Then we can read/write data with socket/file channel in go without
> blocking.
> Thanks,it's really awesome!
>
>
>
>
> 2013/7/1 David Pollak <dpollak...@gmail.com>
>
>> Thanks!
>>
>>
>> On Mon, Jul 1, 2013 at 8:13 AM, Sean Corfield <seancorfi...@gmail.com>wrote:
>>
>>> On Sun, Jun 30, 2013 at 4:42 PM, David Pollak <dpollak...@gmail.com>
>>> wrote:
>>> > Looking forward to it
>>> > being published (even as SNAPSHOT) in a Maven repo.
>>>
>>> It's accessible like this:
>>>
>>> (defproject async "0.1.0-SNAPSHOT"
>>>   :description "FIXME: write description"
>>>   :url "http://example.com/FIXME";
>>>   :license {:name "Eclipse Public License"
>>>             :url "http://www.eclipse.org/legal/epl-v10.html"}
>>>   :repositories {"sonatype-oss-public"
>>> "https://oss.sonatype.org/content/groups/public/"}
>>>   :dependencies [[org.clojure/clojure "1.5.1"]
>>>                  [org.clojure/core.async "0.1.0-SNAPSHOT"]])
>>> --
>>> Sean A Corfield -- (904) 302-SEAN
>>> An Architect's View -- http://corfield.org/
>>> World Singles, LLC. -- http://worldsingles.com/
>>>
>>> "Perfection is the enemy of the good."
>>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>>
>>> --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>  --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> 庄晓丹
> Email:        killme2...@gmail.com xzhu...@avos.com
> Site:           http://fnil.net
> Twitter:      @killme2008
>
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to