p-queue icon indicating copy to clipboard operation
p-queue copied to clipboard

Timeout option question

Open Vedinsoh opened this issue 2 years ago • 2 comments

Documentation mentions the following:

Per-operation timeout in milliseconds. Operations fulfill once timeout elapses if they haven't already.

Does that timeout apply to operations waiting in the queue that didn't start yet, those that are running (pending) or both? It's unclear from the text.

Vedinsoh avatar May 09 '23 10:05 Vedinsoh

When you add an operation to the queue, it gets wrapped in an anonymous function that does some prep work before kicking off your code. It's this wrapper that sets up the timeout handler, so the timer doesn't begin until your operation has been dequeued and started!

There doesn't appear to be any way to set a "pending" timeout—that is, a timer that begins when you add the operation and gets cleared if the operation starts before the timer elapses.

alexwforsythe avatar Nov 22 '24 01:11 alexwforsythe

PR welcome to clarify this.

Richienb avatar Jan 04 '25 13:01 Richienb