morristai commented on code in PR #3599:
URL:
https://github.com/apache/incubator-opendal/pull/3599#discussion_r1401284534
##########
core/src/types/list.rs:
##########
@@ -81,42 +90,73 @@ impl Stream for Lister {
}
if let Some(fut) = self.stating.as_mut() {
- let (path, rp) = ready!(fut.poll_unpin(cx));
+ let entry = ready!(fut.poll_unpin(cx));
// Make sure we will not poll this future again.
self.stating = None;
- let metadata = match rp {
- Ok(rp) => rp.into_metadata(),
- Err(err) => {
- self.errored = true;
- return Poll::Ready(Some(Err(err)));
- }
- };
- return Poll::Ready(Some(Ok(Entry::new(path, metadata))));
+ return Poll::Ready(Some(entry));
}
- match ready!(self.lister.poll_next(cx)) {
- Ok(Some(oe)) => {
- let (path, metadata) = oe.into_entry().into_parts();
- if metadata.contains_metakey(self.required_metakey) {
- return Poll::Ready(Some(Ok(Entry::new(path, metadata))));
+ if !self.task_queue.is_empty() {
+ let task = self.task_queue.pop_back();
+ let fut = async move {
+ if let Some(task) = task {
+ let (path, rp) = task.await.map_err(|err| {
Review Comment:
My initial thought was to keep the original code as it was every time, but
this is a very good suggestion🙏. I'll start to try to think in a bigger
picture!
However, since we need to keep the order of entry, we use `VecDeque` as a
queue here. The current implementation polls `back_mut` directly without adding
another future.
##########
core/src/types/list.rs:
##########
@@ -81,42 +90,73 @@ impl Stream for Lister {
}
if let Some(fut) = self.stating.as_mut() {
- let (path, rp) = ready!(fut.poll_unpin(cx));
+ let entry = ready!(fut.poll_unpin(cx));
// Make sure we will not poll this future again.
self.stating = None;
- let metadata = match rp {
- Ok(rp) => rp.into_metadata(),
- Err(err) => {
- self.errored = true;
- return Poll::Ready(Some(Err(err)));
- }
- };
- return Poll::Ready(Some(Ok(Entry::new(path, metadata))));
+ return Poll::Ready(Some(entry));
}
- match ready!(self.lister.poll_next(cx)) {
- Ok(Some(oe)) => {
- let (path, metadata) = oe.into_entry().into_parts();
- if metadata.contains_metakey(self.required_metakey) {
- return Poll::Ready(Some(Ok(Entry::new(path, metadata))));
+ if !self.task_queue.is_empty() {
+ let task = self.task_queue.pop_back();
+ let fut = async move {
+ if let Some(task) = task {
+ let (path, rp) = task.await.map_err(|err| {
Review Comment:
My initial thought was to keep the original code as it was every time, but
this is a very good suggestion🙏. I'll start to try to think in a bigger
picture!
However, since we need to keep the order of entry, we use `VecDeque` as a
queue here. The current implementation polls `back_mut` directly without adding
another future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]