Comments (3)
The std mutex is fine to use in async code as long as locks aren't held across await points; that's where you run into risk of deadlocks. I'd consider improving the comments/docs around this example but wouldn't want to needlessly turn devs away from the simplest solution.
from actix-website.
Like robjtede pointed out. async mutex is more expensive and potential slower when having a short critical session.
Tokio has pointed out this clearly in it's tutorial: https://tokio.rs/tokio/tutorial/shared-state (Use Tokio's asynchronous mutex)
from actix-website.
Closing this for now.
My conclusion is always uses sync mutex when you can. This issue is welcomed to re open or followed discussion if there are reliable soruce pointing otherwise.
from actix-website.
Related Issues (20)
- Can't compile either static file example HOT 2
- Getting started: Indicate that the example code should be written in src/main.rs
- HTTP/2 support works with rustls, docs may be outdated HOT 1
- please preserve my eyesight and add a dark mode HOT 1
- Dangerous tip in Static Files
- ^^ the trait `Responder` is not implemented for `NamedFile` HOT 1
- Broken links HOT 3
- request monospace font HOT 2
- Outdated info in Server section HOT 1
- ACTIX WEB HTTP2 & OPENSSL : not working exact example from actix.rs website HOT 2
- invalid link to match_info in docs HOT 2
- Actix book link broken HOT 1
- Invalid Link in Extractors Tab (in Docs)
- Chunked body request example does not render on website HOT 1
- The `connection_type` method should not be called on `HttpResponseBuilder` instance. HOT 1
- Search functionality HOT 1
- Add more complex middleware example
- Testing example doesn't work HOT 3
- update docusaurus to v3
- Rendering issue with `warning` fence in `static-files.md`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actix-website.