Breaking News: Grepper is joining Read the official announcement!
Check it out

throttle in scala

Sumit Rawal answered on May 17, 2023 Popularity 1/10 Helpfulness 1/10


More Related Answers

  • sleep in scala

  • throttle in scala



    I am not sure what you are trying to do here. Default global ExecutionContext uses as many threads as you have CPU cores. So, that would be your parallelism. If that's still "too many" for you, you can control that number with a system property: "scala.concurrent.context.maxThreads", and set that to a lower number.

    That will be the maximum number of futures that are executed in parallel at any given time. You should not need to throttle anything explicitly.

    Alternatively, you can create your own executor, and give it a BlockingQueue with a limited capacity. That would block on the producer side (when a work item is being submitted), like your implementation does, but I would very strongly advice you from doing that as it is very dangerous and prone to deadlocks, and also much less efficient, that the default ForkJoinPool implementation. 

    Popularity 1/10 Helpfulness 1/10 Language scala
    Source: Grepper
    Tags: scala
    Link to this answer
    Share Copy Link
    Contributed on May 17 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.