Giter Club home page Giter Club logo

Comments (3)

cameron314 avatar cameron314 commented on June 18, 2024

There is a blocking version of the queue (added not too long ago) that will make your job easier -- it handles all the blocking on dequeue using a lightweight semaphore (fast when the queue still has items, and doesn't spin-wait forever when it's empty). It doesn't have any blocking enqueue operations, though (that may be an interesting feature to add, though -- I'll have to think about it more).

As for enumerating the contents, I'm afraid that's far more tricky. Even under the assumption that all other threads are stopped, it's entirely possible that the memory effects of operations done on those threads are not yet propagated to the CPU core on which the GC thread is running, which means items might be "missed" even if they're actually logically in the queue. It depends on how the other threads are paused -- there would have to be a memory barrier just before pausing that release all changes to the GC thread, and the GC thread would need a corresponding memory barrier after that point to acquire all those changes.

from concurrentqueue.

skaller avatar skaller commented on June 18, 2024

The world stop operation I use has a flag which is checked under a mutex which acts as a full barrier. It's a cooperative stop. Which is rather unfortunate.

However I have to back off my original need for blocking enqueue and dequeue. I have a queue already that does that (and allows enumerating all elements). I also have monitors. I'm using blocking condition variables/semaphores. Unfortunately that leads to a deadlock so I'm right now having to change all blocking operations to used timed waits that loop around and also check the world stop flag.

When a thread stops, it does a setjump() to save all the registers on the stack and then it saves its stack to a control object so the GC can scan all the thread stacks as roots.

With heavy trickery on some OS better can be done but its hard to provide a portable GC whilst still using C/C++ and OS native operations (Posix/Linux, OSX, Windows at least). OTOH any language without a GC is screwed.

from concurrentqueue.

cameron314 avatar cameron314 commented on June 18, 2024

I'm continuing to maintain the queue but at this point will not be adding any new features.

from concurrentqueue.

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.