This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-18
Channels
- # announcements (6)
- # aws (1)
- # babashka (47)
- # beginners (50)
- # calva (65)
- # cider (4)
- # clj-commons (1)
- # clj-kondo (44)
- # clojure (150)
- # clojure-europe (41)
- # clojure-nl (4)
- # clojure-spec (1)
- # clojure-sweden (4)
- # clojure-uk (6)
- # clojurescript (15)
- # clr (1)
- # conjure (1)
- # core-async (7)
- # cursive (5)
- # datomic (12)
- # events (2)
- # fulcro (17)
- # graphql (12)
- # introduce-yourself (1)
- # jackdaw (5)
- # jobs (2)
- # lsp (52)
- # malli (5)
- # meander (3)
- # minecraft (2)
- # missionary (2)
- # off-topic (10)
- # other-languages (9)
- # reitit (9)
- # remote-jobs (1)
- # ring (8)
- # rum (7)
- # shadow-cljs (9)
- # sql (2)
- # tools-deps (20)
- # xtdb (12)
in this case, the shutdown hook may even be triggered to run after the daemon threads servicing the core.async thread pool have terminated, which is potentially problematic if you are are blocking waiting on channels being written to
it's better to close!
the channels, instead of blocking+waiting+finishing thread?
There is no requirement that you close channels, they are not a global resource that needs managing, the garbage collector will collect that when they aren't referenced anymore
If you are using go blocks, those are translated into callbacks on channels, inverting the normal reference direction(normal a running thread is a gc root and has references via it's stack to objects)
So a go block waiting on a channel will not keep the channel from getting gc'ed if there are no other references to it
I might be missing something, but the only reason to have a shutdown hook is to manage a resource that lives outside the vm. I would create the shutdown hook inside the code that interacts with that resource (eg. finalizing the state of some IPC or file) if it's needed. Otherwise I can't think of why I would even need it.