Skip to content

Commit 10fb0a3

Browse files
committed
Merge branch 'master' into dev-io-thread
2 parents 4bd22d1 + f295e03 commit 10fb0a3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/main/clojure/clojure/core/async.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ to catch and handle."
9191
buffer must be specified. ex-handler must be a fn of one argument -
9292
if an exception occurs during transformation it will be called with
9393
the Throwable as an argument, and any non-nil return value will be
94-
placed in the channel."
94+
placed in the channel. Channels implement Datafiable; use datafy
95+
to obtain the state of the channel and its buffer."
9596
([] (chan nil))
9697
([buf-or-n] (chan buf-or-n nil))
9798
([buf-or-n xform] (chan buf-or-n xform nil))

src/main/clojure/clojure/core/async/impl/channels.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,15 @@
303303
(add! buf val)
304304
(catch Throwable t
305305
(handle buf exh t)))))))))
306+
307+
(extend-protocol clojure.core.protocols/Datafiable
308+
ManyToManyChannel
309+
(datafy [c]
310+
(let [b (.buf c)]
311+
{:buffer-type (if b
312+
(-> b class .getSimpleName symbol)
313+
:none)
314+
:buffer-count (count b)
315+
:put-count (count (.puts c))
316+
:take-count (count (.takes c))
317+
:closed? (impl/closed? c)})))

0 commit comments

Comments
 (0)