-
Hey folks! Is it safe to use Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
In general, yes, using So for example, if your It's worth noting that there are some cases that don't follow this rule, but still cannot deadlock, however, the rule can be followed in most cases. One case that doesn't follow the rule but is still ok is when the The article Async: What is blocking? discusses this issue a bit in the section on dedicated threads. It is also discussed here. |
Beta Was this translation helpful? Give feedback.
In general, yes, using
block_on
at the top level of aspawn_blocking
is supported, but if you make use of this feature, there are certain types of behavior that can deadlock (this applies tospawn_blocking
in general, whether or not you useblock_on
inside it). One rule you can follow which guarantees that you have no deadlocks due to thespawn_blocking
pool capacity is that any task running on it (usingblock_on
or not) should eventually exit on its own even if all other threads were paused for the full duration of thespawn_blocking
call.So for example, if your
spawn_blocking
task cannot complete until some otherspawn_blocking
task completes, then this can cause a deadlock given enoug…