Re: Promise/Deliver use cases

2010-01-30 Thread Steven E. Harris
Jeff Rose writes: >Getting with a timeout versus without one is the difference of: > > ; blocking deref > @p > > ; deref with 100ms timeout > (.get (future @p) 100 TimeUnit/MILLISECONDS) But the former just blocks on the promise being delivered, while the latter creates an anonymous function, cr

Re: Promise/Deliver use cases

2010-01-25 Thread Jeff Rose
It might be nice to have a built-in mechanism to get with a timeout. Maybe (await-for ...) could be modified to work on both agents and promises? Note though, that getting a promise with a timeout doesn't require explicitly closing over the promise. The anonymous function that is created in the o

Re: Promise/Deliver use cases

2010-01-23 Thread Richard Newman
You're right. Here's a recursive example of what I was trying to do with promise/deliver: http://gist.github.com/284957 And with delay/force: http://gist.github.com/284972 Nice comparison, thanks for sharing. I suppose the one thing I like about promise/deliver is that promises can be "w

Re: Promise/Deliver use cases

2010-01-23 Thread David Nolen
On Sat, Jan 23, 2010 at 7:43 PM, Richard Newman wrote: > Use futures and promises for parallelism or dataflow-style work. Use delay > for non-parallel, synchronous delayed execution. You're right. Here's a recursive example of what I was trying to do with promise/deliver: http://gist.github.co

Re: Promise/Deliver use cases

2010-01-23 Thread Richard Newman
delay/force definitely do not do what I'm describing. What we want to is something like a continuation as mentioned by Chouser. We want to block the thread of execution until some point in the future when the values become available. I'm not sure that what you described describes what you w

Re: Promise/Deliver use cases

2010-01-23 Thread Steven E. Harris
Jeff Rose writes: > The future is used because they have a timeout feature when using the > .get method. Should there be a corresponding timeout-based `deref' function¹ ("deref-within"?) for promises? Having to close a function over your "@p" form and spawn a job on a separate thread seems like

Re: Promise/Deliver use cases

2010-01-23 Thread Jeff Rose
In a library for communicating with networked programs and devices using Open Sound Control (OSC) messages, I use promises in combination with futures to provide synchronous callbacks with an optional timeout. For example, you might send a status request message to a device and you expect an immed

Re: Promise/Deliver use cases

2010-01-22 Thread Steven E. Harris
Baishampayan Ghose writes: > It would be great if someone pointed out some example usage of > promise/deliver. I've used them in cases where I think I need a future, but I don't want to wrap the future around some function just to catch and propagate its result elsewhere. In Clojure, the `future

Re: Promise/Deliver use cases

2010-01-22 Thread David Nolen
On Fri, Jan 22, 2010 at 11:41 AM, Laurent PETIT wrote: > David, > > maybe I don't understand your example well, but anyway, here are my > remarks / concerns: > > * You're example is not at all exempt from multithreading: you use > futures, and in the real scenario, the calls to deliver would have

Re: Promise/Deliver use cases

2010-01-22 Thread Chouser
On Thu, Jan 21, 2010 at 6:19 AM, Baishampayan Ghose wrote: > > It would be great if someone pointed out some example usage of > promise/deliver. I've used them to convert a callback-based (continuation-passing style, if you will) API into a blocking one. The lib I was using provides something y

Re: Promise/Deliver use cases

2010-01-22 Thread Laurent PETIT
David, maybe I don't understand your example well, but anyway, here are my remarks / concerns: * You're example is not at all exempt from multithreading: you use futures, and in the real scenario, the calls to deliver would have to occur from a thread able to pull from or be notified by the prog

Re: Promise/Deliver use cases

2010-01-22 Thread David Nolen
They are actually useful even outside the context of concurrency. For example perhaps you have a recursive data structure that represents a series of unit tests and unit test suites. You would like to do two things: 1. Render out the nested structure of the tests that will be executed for the user

Re: Promise/Deliver use cases

2010-01-21 Thread Sean Devlin
Promises (and dataflow programming in general) are really useful with interacting with physical devices, especially robots. Suppose you have a 200 ton press, with a safety sensor. You have the following code: (def is-it-safe? (promise)) (defn activate-press [] (if @is-it-safe? (go!))) (d

Re: Promise/Deliver use cases

2010-01-21 Thread Laurent PETIT
In a nutshell, those are the building blocks for the "dataflow programming paradigm". It's an easy way to make a computation done in thread A (and using a pre-declared promise) block until thread B has delivered the promise (given it its value). The book CTM covers dataflow programming : http://w

Promise/Deliver use cases

2010-01-21 Thread Baishampayan Ghose
Hello, I am trying to understand the use-cases of the new promise/deliver feature in Clojure. I have tried using them, and they seem to be pretty straight-forward to use, but unfortunately I haven't been able to understand its use-cases. It would be great if someone pointed out some example usage