Skip to content

feat: add priority task queue with concurrency control#9

Merged
dsm20 merged 1 commit intomainfrom
demo-feature-2
Apr 30, 2026
Merged

feat: add priority task queue with concurrency control#9
dsm20 merged 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

github-actions Bot commented Apr 29, 2026

Comprehension Gate

Answer the questions below in order to merge.

Q1. When a task is added with a priority value, how is its position determined in the internal queue?

  • A) Tasks are always added to the end of the queue, regardless of priority.
  • B) Tasks are added to the beginning of the queue if their priority is higher than the first task.
  • C) Tasks are inserted before the first task in the queue that has a lower priority.
  • D) Tasks are inserted after the last task in the queue that has a higher or equal priority.

Q2. Consider a TaskQueue instance with concurrency = 2. If 5 tasks are added sequentially and then pause() is called immediately after the 5th task is added, how many tasks will be actively running when pause() is invoked?

  • A) 0 tasks, because pause() will prevent any new tasks from starting.
  • B) 1 task, as the process loop will only execute one task before pause() takes effect.
  • C) 2 tasks, as the process method would have initiated up to the concurrency limit before pause() prevents further starts.
  • D) 5 tasks, because pause() only affects tasks added after it's called.

Q3. What is the primary mechanism by which the drain() method signals completion when the queue is empty and no tasks are running?

  • A) It periodically polls the queue and running task counts until they are zero.
  • B) It immediately resolves a Promise if the queue is empty and no tasks are active, otherwise it adds a resolver to a list.
  • C) It rejects with an error if called when tasks are still running or pending.
  • D) It returns a synchronous boolean indicating whether the queue is drained.

Reply in a format like this:

1. A
2. C
3. B

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

Result — PASSED

Score: 3/3 | Q1: PASS | Q2: PASS | Q3: PASS

Comprehension gate passed — this PR is cleared to merge.

@dsm20
Copy link
Copy Markdown
Owner Author

dsm20 commented Apr 29, 2026

  1. C
  2. C
  3. B

@dsm20 dsm20 merged commit 9bb5ebb into main Apr 30, 2026
3 checks passed
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