Git Product home page Git Product logo

Comments (5)

alexcrichton avatar alexcrichton commented on June 5, 2024 1

Ah right whoops, returns the previous not the current count.

from futures-rs.

alexcrichton avatar alexcrichton commented on June 5, 2024

Unfortunately the Inner structure is also referenced by all of the worker threads, so a Drop implementation wouldn't work b/c it's still alive.

It is a bit ad-hoc, though, here, and I'd love to fix!

from futures-rs.

pmarcelll avatar pmarcelll commented on June 5, 2024

I found a bug, the return value of the fetch_sub here will never be 0.

from futures-rs.

alexcrichton avatar alexcrichton commented on June 5, 2024

Ah yeah when I was reviewing this I ended up locating 8592070, is that the bug you were thinking of?

from futures-rs.

pmarcelll avatar pmarcelll commented on June 5, 2024

No, it still leaks in my opinion.

Here is the code:

    // in new()
    let pool = CpuPool {
        inner: Arc::new(Inner {
            queue: MsQueue::new(),
            cnt: AtomicUsize::new(1), // <- starts with 1
            size: size
        }),
    };

// ...

impl Drop for CpuPool {
    fn drop(&mut self) {
        if self.inner.cnt.fetch_sub(1, Ordering::Relaxed) != 0 {
            // when only one instance is left, and it's being destroyed, fetch_sub returns 1, cnt becomes 0,
            // but this always returns here, because fetch_sub retruned 1, and not 0
        }
        // this never gets called
        for _ in 0..self.inner.size {
            self.inner.queue.push(Message::Close);
        }
    }
}

from futures-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.