You don’t always, but you should know enough about it before calling. Even so, calling complex code in a class initialisation is just bad.
This code is literally someone who knew how to creat a deadlock saying hey it’s a deadlock. Interesting because it’s hidden, but practically not something you’d do.
I really don't like repeating myself. But you can't just determine from the call site what that thing you're calling does with your closure.
So if you want to be sure, you have two options:
Inspect the entire tree of code into whatever you're using and make sure the implementation doesn't call from another thread. Make sure to repeat that process every time you update your dependencies.
9
u/[deleted] Mar 21 '21
You don’t always, but you should know enough about it before calling. Even so, calling complex code in a class initialisation is just bad.
This code is literally someone who knew how to creat a deadlock saying hey it’s a deadlock. Interesting because it’s hidden, but practically not something you’d do.