'How to choose between block_in_place and spawn_blocking?

I'm working a lot with tokio and I've been using spawn_blocking for code that is going to block the thread. Then I saw the documentation for block_in_place and it seems like it's an unrestricted (Send, 'static) version of the former.

My question is, if I'm already on a threaded runtime, when is using block_in_place not advisable? What are the differences and advantages of each method of driving sync code? Can it be a problem if I block_in_place a lot, for example, in all my threads at the same time? How does it work?

I read all of the tokio documentation and didn't find the answer to these questions, so it felt right to ask here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source