================ @@ -7,27 +7,43 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/MainLoopBase.h" +#include <chrono> using namespace lldb; using namespace lldb_private; -void MainLoopBase::AddPendingCallback(const Callback &callback) { +void MainLoopBase::AddCallback(const Callback &callback, TimePoint point) { + bool interrupt_needed; { std::lock_guard<std::mutex> lock{m_callback_mutex}; - m_pending_callbacks.push_back(callback); + // We need to interrupt the main thread if this callback is scheduled to + // execute at an earlier time than the earliest callback registered so far. + interrupt_needed = m_callbacks.empty() || point < m_callbacks.top().first; + m_callbacks.emplace(point, callback); } - TriggerPendingCallbacks(); + if (interrupt_needed) ---------------- Jlalond wrote:
If I understand the logic here, we're checking before emplacement if an interrupt is needed and then once we emplace we Interrupt, - Why are we setting interrupt needed when callbacks is empty? - Should we invert this where we trigger the interrupts before a potentially long emplace (this is in response to my nanoseconds fidelity question) https://github.com/llvm/llvm-project/pull/112895 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits