zclllyybb commented on code in PR #27653:
URL: https://github.com/apache/doris/pull/27653#discussion_r1406326157


##########
be/src/pipeline/pipeline_x/dependency.h:
##########
@@ -190,6 +190,58 @@ class RuntimeFilterTimer {
     IRuntimeFilter* _runtime_filter;
 };
 
+struct RuntimeFilterTimerQueue {
+    constexpr static int64_t interval = 50;
+    void run() { _thread.detach(); }
+    void start() {
+        while (!_stop) {
+            std::unique_lock<std::mutex> lk(cv_m);
+
+            cv.wait(lk, [this] { return !_que.empty() || _stop; });
+            {
+                std::unique_lock<std::mutex> lc(_que_lock);
+                std::list<std::shared_ptr<pipeline::RuntimeFilterTimer>> 
new_que;
+                for (auto& it : _que) {
+                    if (it.use_count() == 1) {
+                        it->call_has_release();
+                    } else if (it->has_ready()) {
+                        it->call_has_ready();
+                    } else {
+                        int64_t ms_since_registration = MonotonicMillis() - 
it->registration_time();
+                        if (ms_since_registration > it->wait_time_ms()) {
+                            it->call_timeout();
+                        } else {
+                            new_que.push_back(std::move(it));
+                        }
+                    }
+                }
+                new_que.swap(_que);
+            }
+            std::this_thread::sleep_for(std::chrono::milliseconds(interval));
+        }
+        delete this;

Review Comment:
   I think this logic is workable. But maybe a better way is make this class in 
the thread. so that the class object's lifecycle could be totally in the thread 
and managed by the thread(i.e. RAII). then there's no need to use `delete this` 
to control the lifecycle.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to