Skip to content

feat: add priority task queue with concurrency control#8

Closed
dsm20 wants to merge 1 commit intomainfrom
demo-feature-2
Closed

feat: add priority task queue with concurrency control#8
dsm20 wants to merge 1 commit intomainfrom
demo-feature-2

Conversation

@dsm20
Copy link
Copy Markdown
Owner

@dsm20 dsm20 commented Apr 29, 2026

No description provided.

@github-actions
Copy link
Copy Markdown

Comprehension Gate

Answer the questions below in order to merge.

Q1. When a task is added to the queue using add(fn, { priority }), how is its position determined if multiple tasks have the same priority?

  • A) It is always added to the end of the queue, regardless of priority.
  • B) It is inserted before the first task with a lower priority; if all existing tasks have equal or higher priority, it's added to the end.
  • C) It is inserted after the last task with an equal or higher priority, maintaining a stable order.
  • D) The implementation does not guarantee a specific order for tasks with identical priorities; it depends on the iteration order of findIndex.

Q2. What is the primary purpose of the drain() method, and when does it resolve?

  • A) It stops all currently running tasks and clears the queue, resolving immediately.
  • B) It pauses the queue and resolves when all currently running tasks complete.
  • C) It returns a Promise that resolves when all tasks, both running and pending, have completed their execution.
  • D) It resolves when the queue is empty, but only if pause() has been called previously.

Q3. Consider a scenario where clear() is called. What happens to tasks that are currently running at the time of the call?

  • A) Running tasks are immediately aborted and their promises are rejected.
  • B) Running tasks are allowed to complete normally, but their results are discarded, and their promises are neither resolved nor rejected by the queue.
  • C) Running tasks continue to execute until completion, and their promises will resolve or reject as usual, independent of the clear() operation.
  • D) Running tasks are paused and their execution is resumed if resume() is called later.

Reply in a format like this:

1. A
2. C
3. B

Questions are based on commit 02405d7. Pushing new commits regenerates the questions.

@dsm20 dsm20 closed this Apr 29, 2026
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

Successfully merging this pull request may close these issues.

1 participant