Created
September 5, 2017 13:11
-
-
Save RutledgePaulV/ec88ef7c8d168342a1c47f14b52d1c0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn attach-channel-cleanup [chan f] | |
(add-watch (.closed chan) | |
"channel-resource-cleanup" | |
(fn [_ _ old-state new-state] | |
(when (and (not old-state) new-state) | |
(f)))) | |
chan) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used to make sure that any resources driving the inputs to the channel (like a network connection) are cleaned up when the channel is closed (regardless of who closes it or when).