(defn chan
([buf] (chan buf nil))
([buf xform] (chan buf xform nil))
([buf xform exh]
(ManyToManyChannel.
(LinkedList.) (LinkedList.) buf (atom false) (mutex/mutex)
(let [add! (if xform (xform impl/add!) impl/add!)]
(fn
([buf]
(try
(add! buf)
(catch Throwable t
(handle buf exh t))))
([buf val]
(try
(add! buf val)
(catch Throwable t
(handle buf exh t)))))))))