-
The 'set_stopped' completion function doesn't allow a value to be passed in unlike set_value/set_error. In my case, I would like to pass a reason to 'set_stopped' completion function. io_uring has a multi-shot receive operation, where you make a single request, and you get multiple outputs. However, the request can expire at any time. When it does expire, I want to invoke 'set_stopped' and pass in some value representing the fact that the request stopped on its own. There is also some other data I want to pass back to set_stopped. Currently, i'm just using set_error for both cancellations/errors, and differentiating which it is based on the type of the value passed back. What do you think? I've only just started experimenting with this library/P2300 so not sure if there is a way to achieve what I want. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Does your sender complete when the whole multi-shot operation completes? In my understanding, you would complete with If you need to expose each single read operation, using something like a sequence-sender might be more appropriate. |
Beta Was this translation helpful? Give feedback.
-
Completing any receiver more than once with set_value is certainly wrong! In general receivers can and do expect that there is only one call to any of their 3 completion signatures.You may want to have a look at set_next: you’d report partial tesults ising set_next and upon completion you’d complete with set_value, possibly not providing another value rather nothing or some sort of report.On 9 Aug 2023, at 23:02, Baber Nawaz ***@***.***> wrote:
Hi, thanks for the response.
The approach I've taken with io_uring multi-shot ops:
Create a sender and allocate an operation state by connecting it with a receiver
For each output of the multi-shot op, I invoke set_value() on the SAME receiver (operation state is kept alive)
When set_stopped/set_error is invoked, the multi-shot op is done and no more set_value are to be invoked
Not sure if it's a correct way of doing it, in very early stages at the moment, have not yet done a test run.
Thanks for your partial sum suggestion (though, I would prefer not to have any error_code in set_value completion). My current approach is basically same or similar to your suggestion:
I first invoke set_value with the "partial" result
then I invoke set_stopped
However, I hit an issue with the second point because I couldn't pass in any data to set_stopped. I will just use set_error for both cancellations/errors I guess since I can pass data through it.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Does your sender complete when the whole multi-shot operation completes? In my understanding, you would complete with
set_stopped()
when an outer cancelation request happens. I would write an algorithm that completes with some "partial sum" result when the multi-shot op has stopped or needs to be rescheduled.If you need to expose each single read operation, using something like a sequence-sender might be more appropriate.