8000 Merge pull request #5 from erikprice/close-defasyncs · DavidAlphaFox/postgres.async@ee1031f · GitHub
[go: up one dir, main page]

Skip to content

Commit ee1031f

Browse files
committed
Merge pull request alaisi#5 from erikprice/close-defasyncs
close! channels created in defasync functions
2 parents fc3124f + f159890 commit ee1031f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/postgres/async/impl.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
(ns postgres.async.impl
22
(:require [clojure.string :as string]
3-
[clojure.core.async :refer [chan put! go]])
3+
[clojure.core.async :refer [chan close! put! go]])
44
(:import [java.util.function Consumer]
55
[com.github.pgasync ResultSet]
66
[com.github.pgasync.impl PgRow]))
77

88
(defmacro defasync [name args]
99
`(defn ~name [~@args]
1010
(let [c# (chan 1)]
11-
(~(symbol (subs (str name) 1)) ~@args #(put! c# (or %2 %1)))
11+
(~(symbol (subs (str name) 1)) ~@args #(do
12+
(put! c# (or %2 %1))
13+
(close! c#)))
1214
c#)))
1315

1416
(defmacro consumer-fn [[param] body]

0 commit comments

Comments
 (0)
0