Code Monkey home page Code Monkey logo

Comments (3)

robjtede avatar robjtede commented on May 20, 2024 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.

fakeshadow avatar fakeshadow commented on May 20, 2024 3

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.

fakeshadow avatar fakeshadow commented on May 20, 2024 2

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.