Giter Site home page Giter Site logo

Comments (2)

gammazero avatar gammazero commented on July 20, 2024

The priority queues I have generally seen use separate channels for different priorities, all feeding the same pool of goroutines. The highest priority channel is serviced until empty before servicing the next lower priority channel, and so on... I assume you doing something similar and feeding tasks to this worker pool.

The problem is that this workerpool is designed to be a non-blocking pool that you throw as many tasks at as you like without ever having to wait, even if that task is not immediately runnable. What you probably need is a blocking workerpool. So that when there are no available workers, the pool will not accept another task, and your tasks will stack up in the appropriate queues or channels.

To respond to your suggestion above, I do not think checking the number of active workers will be very reliable as that may become completely different immediately after the check. If that is still needed, then have the functions that are called increment and decrement a counter on entry and exit (or create a generic wrapper that does that).

A blocking implementation would be much simpler since most of the complexity in this workerpool arises from needing to handle queuing tasks when all workers are busy.

from workerpool.

radeksimko avatar radeksimko commented on July 20, 2024

That is fair. I did eventually implement a custom worker pool with priority handling https://github.com/hashicorp/terraform-ls/blob/main/internal/terraform/module/module_loader.go

Your workerpool implementation did help us get things off the ground at the beginning, but it became clear later that we have a little more complex needs.

So with that in mind I'm going to close this issue.

from workerpool.

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.