Navigation Menu

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

question: check an async.queue to see if a matching task has already been inserted? #1459

Closed
PsyTae opened this issue Jul 27, 2017 · 3 comments

Comments

@PsyTae
Copy link

PsyTae commented Jul 27, 2017

Is there anyway to look at the tasks of a current queue to determine if the task you are about to put in might already match a task currently in the queue?

@aearly aearly added the queue label Jul 27, 2017
@aearly
Copy link
Collaborator

aearly commented Jul 27, 2017

There is no officially sanctioned way to iterate the queue. There is a q._tasks property that exposes the underlying linked list for the queue. You can either iterate the linked list, or call q._tasks.toArray().find(...) to see if your task already exists.

This is an implementation detail, so it is not documented. It might break in the future if we change how the queue works internally.

@aearly
Copy link
Collaborator

aearly commented Jul 27, 2017

Although, as an enhancement to the queue, we could expose a q[Symbol.iterator] property for exposing an implementation-agnostic way to iterate the current items of the queue.

@ofek-a
Copy link

ofek-a commented Aug 12, 2017

I would also like this feature, many other queues have this feature.
q.contains(task) would be very useful!

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

No branches or pull requests

3 participants