async icon indicating copy to clipboard operation
async copied to clipboard

`Async::Queue#signal` does not default `value` to `nil`

Open oeoeaio opened this issue 1 year ago • 4 comments

#276 introduced a breaking change to the public interface of Queue. Prior to #276 #signal was inherited from Notification where value is defaulted to nil if it is not provided.

The new implementation of Queue#signal does not provide a default. Our implementation calls this method without an argument, and so now we are getting the following exception:

ArgumentError wrong number of arguments (given 0, expected 1)

oeoeaio avatar Aug 26 '24 05:08 oeoeaio

Apologies for this breaking change.

Considering your investigation, do you think we should restore the default behaviour? If so, do you mind submitting a PR?

ioquatix avatar Aug 26 '24 08:08 ioquatix

I can make a PR, but it feels to me like the semantics of the #signal method have fundamentally changed, so I'm not sure I fully understand the expected behaviour. Before, a Queue was a Notification, but now it wraps a Notification (@available). The new #signal implementation is basically an alias for #enqueue, and there is no way to directly signal to the wrapped Notification without the byproduct of adding an item to the queue. If I just default the value to nil then a nil item will be added to the queue, which I don't think it appropriate. It's possible that our implementation is now outdated, and we don't need to call #signal anymore to achieve the same result.

For context our use of #signal is related to https://github.com/socketry/async/issues/176, which looks to have been resolved by #187. I will test whether the issue still exists in the absence of the #signal call, and if not, I will just remove it from our implementation.

oeoeaio avatar Aug 27 '24 04:08 oeoeaio

Confirmed, it looks like v2.3.0 which includes the changes in #187 fixed our issue, and we just haven't checked since then. So we can just remove the #signal call completely. I'm not sure what this means for the breaking change, but hopefully no-one else is using it in the same way we were.

oeoeaio avatar Aug 27 '24 04:08 oeoeaio

Awesome, let's keep this open and when I have time to review it in detail, I'll make a decision.

ioquatix avatar Aug 27 '24 05:08 ioquatix

I'm okay with following the same contract as Notification#signal.

ioquatix avatar Oct 29 '24 21:10 ioquatix