Git Product home page Git Product logo

Comments (4)

fereidani avatar fereidani commented on July 28, 2024

Hi, Thanks for the issue, I found some dead code in the project because of it, But it's incorrect, Waker is registered here before pushing the signal to the signal list:

kanal/src/future.rs

Lines 92 to 97 in ac93742

*this.state = FutureState::Waiting;
this.sig.set_ptr(this.data.as_mut_ptr());
this.sig.register(cx.waker());
// send directly to the waitlist
internal.push_send(this.sig.as_signal());
drop(internal);

and

kanal/src/future.rs

Lines 179 to 185 in ac93742

*this.state = FutureState::Waiting;
this.sig.set_ptr(this.data.as_mut_ptr());
this.sig.register(cx.waker());
// no active waiter so push to the queue
internal.push_recv(this.sig.as_signal());
drop(internal);
Poll::Pending

and this code was a dead code that I forgot to remove:

     { 
         self.waker = Some(cx.waker().clone()) 
     } 

so before pushing the signal to the queue, the waker is already registered, and the possibility of lost wake-ups does not exist.

Feel free to close the issue if you think my explanation is clear.

from kanal.

sbarral avatar sbarral commented on July 28, 2024

So as I wrote in the sibling issue: you need to re-register the waker every time because it can change every time poll is called, so the dead code was actually something that should be done, albeit safely.

from kanal.

fereidani avatar fereidani commented on July 28, 2024

Let's continue that subject in #14

from kanal.

fereidani avatar fereidani commented on July 28, 2024

Fixed as discussed in #14

from kanal.

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.