Fork me on GitHub
#core-async
<
2022-01-18
>
hiredman00:01:50

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

👍 1
Ian Fernandez01:01:17

it's better to close! the channels, instead of blocking+waiting+finishing thread?

hiredman04:01:14

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

hiredman04:01:15

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)

hiredman04:01:01

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

noisesmith18:01:35

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.