I think the fib example is a good one in the sense that you are dealing
with an already function that takes a long time, and isn't written as a
loop.

But in general, I want to solve the problem for an arbitrary long-running
computation, for example, a call into a library that you don't control.

One of the flagship examples for core.async is the example where you try
two different engines to look something up, return the first one or
timeout.  Similarly, I want to try to solve a computational problem two
different ways, and take the first solution or timeout.  But of course,
that only works if I can stop the computation from spinning CPU once I
already have a solution (or timeout).

Rewriting the underlying algorithms to constantly check for an interrupt is
not an option.




On Wed, Jan 22, 2014 at 11:31 AM, Praki Prakash <praki.prak...@gmail.com>wrote:

> What is the task doing? If it is in a tight loop, it must check explicitly
> whether the interrupt flag is set and abort. If it is waiting on some
> resource, it will receive InterruptedException.
>
> Regards,
> Praki Prakash
>
>
> On Wed, Jan 22, 2014 at 11:20 AM, Mark Engelberg <mark.engelb...@gmail.com
> > wrote:
>
>> On Wed, Jan 22, 2014 at 2:51 AM, Jozef Wagner <jozef.wag...@gmail.com>wrote:
>>
>>> You can put the computation into a future, and cancel the future after
>>> the timeout.
>>>
>>
>> I experimented with that, but it didn't seem to work.  I suspect that
>> "canceling a future" doesn't really do what I think it should do.  I would
>> appreciate some further clarity on how future cancellations work, and if
>> someone thinks it applies here, would like to see concretely how to do it.
>>
>> --
>> --
>> 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.
>

-- 
-- 
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