From cea0e3d60f4c39840db6e892d78c8f871a8894e6 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Thu, 13 Oct 2016 12:00:49 -0700 Subject: [PATCH] Review comment: return pair-chan; accept a result chan and close? flag. --- src/common/datomish/transact.cljc | 22 +++++++++++++--------- test/datomish/transact_test.cljc | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/common/datomish/transact.cljc b/src/common/datomish/transact.cljc index 58e0d33a..bc62ff05 100644 --- a/src/common/datomish/transact.cljc +++ b/src/common/datomish/transact.cljc @@ -570,13 +570,16 @@ "Submits a transaction to the database for writing. Returns a pair-chan resolving to `[result error]`." - [conn tx-data] - {:pre [(conn? conn)]} - (let [result (a/chan 1)] - ;; Any race to put! is a real race between callers of ! token-chan (gensym "transactor-token")) (loop [] (let [token (! (:listener-source conn) report) report)))] (>! result pair)) - (a/close! result) (>! token-chan token) + (when close? + (a/close! result)) (recur))))))) (defn listen-chan! diff --git a/test/datomish/transact_test.cljc b/test/datomish/transact_test.cljc index 05e28698..1436eea9 100644 --- a/test/datomish/transact_test.cljc +++ b/test/datomish/transact_test.cljc @@ -98,8 +98,8 @@ ;; Wait for all transactions to complete. (