Git Product home page Git Product logo

Comments (7)

Ericson2314 avatar Ericson2314 commented on July 19, 2024

Are you putting the RefCell inside the Once or the Once inside the RefCell?

from spin-rs.

Ericson2314 avatar Ericson2314 commented on July 19, 2024

If you mean

MyOtherSyncronization<RefCell<Once<T>>

You probably don't want Once because you don't need the syncronization it provides.

Once itself does hand off & to concurrent readers, so it needs Sync just like RwLock as it says in the comment. Your case is special since & isn't being handed out so liberally. The solution with Once would be a wrapper type with an unsafe impl.

from spin-rs.

boomshroom avatar boomshroom commented on July 19, 2024

What I have is &Mutex<Trait> and struct Value(Once<RefCell<InnerValue>>) with impl Trait for Value. Really what I want is mutable access to the inner value after having mutable access to the Once itself.

from spin-rs.

Ericson2314 avatar Ericson2314 commented on July 19, 2024

@boomshroom ah ok yes that is reasonable. Sorry I forgot about the get_mut when responding to your OP.

from spin-rs.

mvdnes avatar mvdnes commented on July 19, 2024

We added it because RwLock had it too. However, in stdlib it was removed in rust-lang/rust@fbf6885#diff-0dfca49424f912822edb26b8d93ae2ac.

It seems this would apply here too. Can someone confirm this?

from spin-rs.

Ericson2314 avatar Ericson2314 commented on July 19, 2024

Ah ok that makes sense. Putting the lock in an arc or static will require the sync bound so the end requirements are the same.

Put another way, RwLock puts no less onerous reqirments on T than plane T alone, unlike say Mutex where we can discharge a Sync with Send.

from spin-rs.

Ericson2314 avatar Ericson2314 commented on July 19, 2024

Maybe find original PR? But good with me!

from spin-rs.

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.