vector-stream Batcher doubts #25624
Replies: 1 comment
-
|
After investigating a bit more I have more doubts about that timer. Let us see what is the context and an execution path where that time can be polled. So the batcher stream is used in the driver here. This line wraps the batcher to a ReadyChunks futures which in the futures crate. It basically collects items from the underlying stream and collects them into a Vec. Once it gets a Pending, it returns with the collected chunk. So let us suppose that this batcher reads an item and sets the timer. Then in the next iteration it goes to the Pending branch and polls the timer. This macro returns if the timer is in Pending. So the control goes back to ReadyChunk and it results in Pending, which is correct. In the next calls the Am I right? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to chase a concurrency issue and for that I need to understand what timeout and sleep exactly do in
Batcherpoll_nextfunction. Here it is the codeMy doubt is: why do we set a timeout if there is anything in the batch in line 79.
So what I think happens:
Poll::Ready(None)(line 62) is quite clear: if we reached the end of the stream, depending on what we collected return None or the remaining batchPoll::Pending(line 90) is also okay: if we have a timer set, let us wait 'timeout' duration and give back the batch. If there is nothing in the batch, timer is set to None in line 76, so we don't wait. Also there is a debug assert to cover that inconsistency. If we don't have timer here, we just return PendingPoll::Ready(Some(item))line 71: once we get an item, let us check if it fits in the batch.this.state.len() == 0)Not sure if there is a role of the timeout (quality of service) but I think here we wait at least two times without we need to.
What do others think? Am I confused or have spotted something?
Beta Was this translation helpful? Give feedback.
All reactions