Let me give a short description of each and perhaps that will help explain when each would be preferred:
promise - creates a object that can be deref'd. The result of the promise can be delivered once, and deref-ing a undelivered will cause the deref-ing thread to block. A single producer can give a single value to multiple threads future - just like a promise, but it the delivering code is given to the future and the future will go off and execute that code in a different thread. Single producer delivers a single value produced in a undefined thread, to multiple consumers agents - couples a unbounded queue of functions with a single mutable value. Mutating that value is accomplished by enqueue'ing functions to be executed against that mutable state. Multiple producers use functions to modify a mutable ref. Can be deref-ed by may different consumers channels - allow multiple producers to provide data to multiple consumers on a one-to-one basis. That is to say, a single value put into a channel can only be taken by a single consumer. However, multiple values can be inflight at a single time. This is all delivered by a bounded queue (notice the difference with unbounded agents). This allows for back-pressure, where slow producers can block faster consumers. So perhaps the best way to think about channels is a bounded mutable queue of promises Hopefully this helps a bit, Timothy Baldridge On Thu, Jul 18, 2013 at 10:54 PM, julius <wee....@gmail.com> wrote: > It brother me too. > > Thanks > > > On Friday, July 5, 2013 3:28:54 AM UTC+8, Hussein B. wrote: >> >> Hi, >> >> How core.async compares to agents, future and promise? >> >> When to use core.async and when to use agents, future and promise? >> >> Thanks for help and time. >> > -- > -- > 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. > > > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- -- 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.