Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal pending count out of sync #203

Open
ZhangHanwen96 opened this issue Dec 28, 2023 · 0 comments
Open

internal pending count out of sync #203

ZhangHanwen96 opened this issue Dec 28, 2023 · 0 comments

Comments

@ZhangHanwen96
Copy link

ZhangHanwen96 commented Dec 28, 2023

Lets say I have a queue for 10 tasks,
I want to set it to pending if q.concurrency <= q.pending, before q.add(someTask),

But due to the internal implemetation of 'add()' method, the intertal pending++ got executed in the end of current eventloop, so when I do

items.forEach(item => {
   if(q.concurrency <= q.pending) {
            // set item pending
   } else { 
           // set item loading
   }
})

the current q.pending is not what I expected

Helps appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant