Re: idiomatic terminating infinite loops

2013-05-16 Thread Colin Yates
Thanks both, good suggestions. On 15 May 2013 23:38, "Stuart Sierra" wrote: > Colin Yates wrote: > > I have a scheduler which creates a future that basically > > does a (while true (let [next-job (.take queue)]...)), > > where queue is a LinkedBlockingQueue. The problem is that > > once it is run

Re: idiomatic terminating infinite loops

2013-05-15 Thread Stuart Sierra
Colin Yates wrote: > I have a scheduler which creates a future that basically > does a (while true (let [next-job (.take queue)]...)), > where queue is a LinkedBlockingQueue. The problem is that > once it is running, because futures aren't daemon threads > it hangs lein. Instead of .take, you can

Re: idiomatic terminating infinite loops

2013-05-15 Thread Gary Trakhman
A couple of approaches: 1. Stop using compojure's 'defroutes'. Generate routes via 'routes' that close over your service. Try not to do anything that would make this expensive. 2. Pass it along on a request map via some middleware. The relevant principle: lifecycle of your component and usage sh

idiomatic terminating infinite loops

2013-05-15 Thread Colin Yates
Hi all, I have a scheduler which creates a future that basically does a (while true (let [next-job (.take queue)]...)), where queue is a LinkedBlockingQueue. The problem is that once it is running, because futures aren't daemon threads it hangs lein. It will ultimately run inside a compojure