Hi Stephen,
I don't undersand your suggestion:
(defn foo [c]
(async/>! c "hi"))
(defn test []
(let [c (async/chan 10)]
(async/go
(foo c)
(println (<! c))
)))
(test)
throws an exceptino of (async/>! not used in go block ...
On Mon, Jan 13, 2014 at 12:03 PM, Stephen Cagle <[email protected]> wrote:
> Did you mean
>
>
> *(go (loop [ ... ]*
>
> * (case ...*
>
> * .. (func arg1 foo1)*
>
> * .. (func arg2 foo2)*
>
>
> * .. (func arg3 foo3)))*
>
> *where (defn func [ ... ] (.. >! .. ))*
> , as func (not foo) is the thing in function position?
>
> Ignoring that, and working in a general sense:
>
> I think that if the function you call into is synchronous, then you can
> just <! or >! from within the go block, and call the function in the normal
> fashion.
>
> However, if the function is asynchronous, I think it is probably best to
> make the function itself into a go machine, and just take! on the returned
> channel returned from the go machine. something like
> (defn func [...] (go <DO
> ASYNC_STUFF._LAST_VALUE_IS_VALUE_OF_CHANNEL_RETURNED_BY_FN_CALL> ))
>
> calling it as
> ...
> (<! (func arg1 foo1)).
> ...
>
> Performance wise, I am not clear how expensive it is to spin up a go
> machine every time you make a call to func vs just passing around a channel
> to be processed by a looping go machine.
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.