This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch fix-future
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit 16cd2ce358fa3cd3a0ca9f02e3843d74b147c591
Author: Xuanwo <[email protected]>
AuthorDate: Thu Jan 18 01:07:14 2024 +0800

    fix: Don't call wake_by_ref in OperatorFuture
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/types/operator/operator_futures.rs | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/core/src/types/operator/operator_futures.rs 
b/core/src/types/operator/operator_futures.rs
index 4faf5ea523..50e5fd25eb 100644
--- a/core/src/types/operator/operator_futures.rs
+++ b/core/src/types/operator/operator_futures.rs
@@ -95,22 +95,20 @@ where
     ///
     /// In general, `Empty` state should not be polled.
     fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> 
Poll<Self::Output> {
-        *self = match mem::replace(self.as_mut().get_mut(), 
OperatorFuture::Empty) {
-            OperatorFuture::Idle(inner, path, args, f) => {
-                // Wake up to make sure the future is ready after the
-                // future has been built.
-                cx.waker().wake_by_ref();
-                OperatorFuture::Poll(f(inner, path, args))
+        loop {
+            *self = match mem::replace(self.as_mut().get_mut(), 
OperatorFuture::Empty) {
+                OperatorFuture::Idle(inner, path, args, f) => {
+                    OperatorFuture::Poll(f(inner, path, args))
+                }
+                OperatorFuture::Poll(mut fut) => match fut.as_mut().poll(cx) {
+                    Poll::Ready(v) => return Poll::Ready(v),
+                    Poll::Pending => OperatorFuture::Poll(fut),
+                },
+                OperatorFuture::Empty => {
+                    panic!("future polled after completion");
+                }
             }
-            OperatorFuture::Poll(mut fut) => match fut.as_mut().poll(cx) {
-                Poll::Pending => OperatorFuture::Poll(fut),
-                Poll::Ready(v) => return Poll::Ready(v),
-            },
-            OperatorFuture::Empty => {
-                panic!("future polled after completion");
-            }
-        };
-        Poll::Pending
+        }
     }
 }
 

Reply via email to