function | since v0.0-1503 | Edit |
(connection)
Promise to return a connection when one is available. If no connection is available put the promise into a FIFO queue to get the next available connection.
(defn connection
[]
(locking lock
(let [p (promise)
conn (.poll connq)]
(if (and conn (not (.isClosed conn)))
(deliver p conn)
(.offer promiseq p))
p)))