Async: Remove job from `queue` possible?

Created on 30 Aug 2014  路  2Comments  路  Source: caolan/async

Hi, don't see this in the documentation so i'm checking whether its possible to remove a task from the queue.

I can contribute such feature, if it is not deliberate to not be able to remove tasks.

There might be some concurrency problems where a task is removed when it is running, but i think that could be solved with

  1. Pause queue
  2. Remove the job
  3. Resume queue

What do you think?

question

All 2 comments

It's possible, but it will be very tricky. There are a lot of assumptions in the queue code, mainly that you will only push() jobs on to it, rather than splice. Pausing the queue is also tricky due to other concurrent actions that might be in flight.

You may also want to check out https://www.npmjs.org/package/queue . It aims to implement all the Array.prototype methods in its queue implementation.

it's possible with q._tasks.removeLink ;)

Was this page helpful?
0 / 5 - 0 ratings