-
I just finished this and this tutorials on tokio actors and am left with this impression:
Are there other use-cases when one might want to use actors over a simple event loop? If so, what are they? And am I right in thinking that if it can be done with an event loop, that's the preferred way since it's simpler? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Here's another use-case for actors: If you have a server with many open connections that need to communicate with each other, then wrapping each connection in an actor is usually a good strategy. In my article that you linked, I mention this in the following paragraph:
I usually link to this project as an example of this. It goes through various features of the article:
Of course, you should not use actors just because you like actors. They are a design pattern that is sometimes useful. If you can write the code in a simple way without actors, don't use actors. Web servers usually don't need actors, because there is little communication between different connections to the server. To conclude, use actors when the alternative is more complicated. |
Beta Was this translation helpful? Give feedback.
Here's another use-case for actors: If you have a server with many open connections that need to communicate with each other, then wrapping each connection in an actor is usually a good strategy. In my article that you linked, I mention this in the following paragraph:
I usually link to this project as an example of this. It goes through various features of the article: