Is there a canonical way or framework to handle threads lifecycle?

Hi all, after reading this post:

I started to think about how Clojure deliver to us not only a simpler way to deal with threads and asynchronous primitives from Java in general but also an easier way as well.

But all this can be undermined when one needs to handle the threads lifecycle.

Is there some kind of framework a la Stuart Sierra Components to help us with this? Something like a mini Erlang OTP framework for Clojure?

2 Likes

A sierra-style Component can certainly manage an Executor thread pool! Good practice.

As for the linked article… Very interesting! But isn’t it on quicksand? It requires coordination of all shutdown hooks. If your project involves any third-party stuff that might ever register a shutdown hook, coordination is impossible. Before your shutdown hooks have done their job, the tools they need might already have been dismantled.

Have a look at objection: https://github.com/riverford/objection

I found it very useful for managing life cycles, especially when you don’t want to go through all the hassle of components.

Let me know if you want an example.

2 Likes

[…] mini Erlang OTP framework for Clojure?

There is otplike

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.