Add links to how to deal with blocking APIs #29544 (#29547)

Refs: #29544
Adds a couple of links to dealing with blocking APIs
This commit is contained in:
Josep Prat 2020-09-07 15:10:08 +02:00 committed by GitHub
parent a548949143
commit 9113c07da5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View file

@ -75,7 +75,7 @@ a distributed application.
requests) in an event-driven manner. Actors should not block (i.e. passively
wait while occupying a Thread) on some external entity—which might be a
lock, a network socket, etc.—unless it is unavoidable; in the latter case
see below.
see @ref:[`Blocking Needs Careful Management`](../typed/dispatchers.md#blocking-management).
2. Do not pass mutable objects between actors. In order to ensure that, prefer
immutable messages. If the encapsulation of actors is broken by exposing
their mutable state to the outside, you are back in normal Java concurrency

View file

@ -33,6 +33,10 @@ In contrast, *non-blocking* means that no thread is able to indefinitely delay o
Non-blocking operations are preferred to blocking ones, as the overall progress of the system is not trivially guaranteed
when it contains blocking operations.
It's not always possible to avoid using blocking APIs, please see
@ref:[`Blocking Needs Careful Management`](../typed/dispatchers.md#blocking-management) to use those safely within the
actor code.
## Deadlock vs. Starvation vs. Live-lock
*Deadlock* arises when several participants are waiting on each other to reach a specific state to be able to progress.

View file

@ -137,6 +137,7 @@ Example: configuring `internal-dispatcher` to be an alias for `default-dispatche
akka.actor.internal-dispatcher = akka.actor.default-dispatcher
```
<a id="blocking-management"></a>
## Blocking Needs Careful Management
In some cases it is unavoidable to do blocking operations, i.e. to put a thread