Re: core.async: async java.jdbc

2013-08-01 Thread Jonah Benton
These are interesting code listings and questions, but they conflate the syntactic detail that core.async's go is implemented as a macro, with the semantic intention to support designs around lightweight data flow between independent code blocks. It might be of value to check out Go, the language,

Re: core.async: async java.jdbc

2013-08-01 Thread Alice
What if I want to run a select query in the middle of a transaction? On Thursday, August 1, 2013 3:33:29 AM UTC+9, tbc++ wrote: > > DB work is a IO operation, and IO shouldn't be done inside a go block (go > blocks use limited thread pools). > > So what about something like this? > > (defn handl

Re: core.async: async java.jdbc

2013-07-31 Thread Sean Corfield
On Wed, Jul 31, 2013 at 10:58 AM, Alice wrote: > It doesn't produce a compile time error but I think it's not the correct > code because the transaction can be committed while insert-async! is still > executing. Right. I was just showing how to avoid the compile error (because you need http://cor

Re: core.async: async java.jdbc

2013-07-31 Thread Alice
(defn insert-async! [& args] (db-thread (try (apply jdbc/insert! args) (catch Throwable t t db-thread is a macro that runs the body in a fixed thread pool, so IO isn't done inside a go block. On Thursday, August 1, 2013 3:33:29 AM UTC+9, tbc++ wrote: > > DB work i

Re: core.async: async java.jdbc

2013-07-31 Thread Timothy Baldridge
DB work is a IO operation, and IO shouldn't be done inside a go block (go blocks use limited thread pools). So what about something like this? (defn handle-db [chan] (thread (while true (let [[data result] (! result :done) Now spin up a few of these: (def db-chan (let [c (chan 4)

Re: core.async: async java.jdbc

2013-07-31 Thread Alice
I have an async http handler and I don't want it to consume a thread. On Thursday, August 1, 2013 3:16:52 AM UTC+9, tbc++ wrote: > > Why not use > Timothy > > > On Wed, Jul 31, 2013 at 11:58 AM, Alice >wrote: > >> It doesn't produce a compile time error but I think it's not the correct >> code

Re: core.async: async java.jdbc

2013-07-31 Thread Timothy Baldridge
Why not use wrote: > It doesn't produce a compile time error but I think it's not the correct > code because the transaction can be committed while insert-async! is still > executing. > > On Thursday, August 1, 2013 2:46:29 AM UTC+9, Sean Corfield wrote: > >> On Wed, Jul 31, 2013 at 10:29 AM, Ali

Re: core.async: async java.jdbc

2013-07-31 Thread Alice
It doesn't produce a compile time error but I think it's not the correct code because the transaction can be committed while insert-async! is still executing. On Thursday, August 1, 2013 2:46:29 AM UTC+9, Sean Corfield wrote: > > On Wed, Jul 31, 2013 at 10:29 AM, Alice > > wrote: > > (go > >

Re: core.async: async java.jdbc

2013-07-31 Thread Sean Corfield
On Wed, Jul 31, 2013 at 10:29 AM, Alice wrote: > (go > (jdbc/db-transaction [t-con db-spec] > (http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- -- You received this mess

core.async: async java.jdbc

2013-07-31 Thread Alice
(defonce ^ExecutorService db-thread-pool (Executors/newFixedThreadPool 8)) (defn db-thread-call [f] (let [c (chan 1)] (.execute db-thread-pool (fn [] (let [ret (try (f) (catch Throwable t