From d35031e1e5b1dbe31f960a1054f139f7ba2c3f35 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 30 Nov 2016 10:41:42 +0000 Subject: Use Timeout<> in the Listener class Summary: Communication classes use the Timeout<> class to specify the timeout. Listener class was converted to chrono some time ago, but it used a different meaning for a timeout of zero (Listener: infinite wait, Communication: no wait). Instead, Listener provided separate functions which performed a non-blocking event read. This converts the Listener class to the new Timeout class, to improve consistency. It also allows us to get merge the different GetNextEvent*** and WaitForEvent*** functions into one. No functional change intended. Reviewers: jingham, clayborg, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D27136 llvm-svn: 288238 --- lldb/source/Core/Communication.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lldb/source/Core/Communication.cpp') diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp index 113a847953d..3d3abea6248 100644 --- a/lldb/source/Core/Communication.cpp +++ b/lldb/source/Core/Communication.cpp @@ -115,8 +115,6 @@ bool Communication::HasConnection() const { size_t Communication::Read(void *dst, size_t dst_len, const Timeout &timeout, ConnectionStatus &status, Error *error_ptr) { - using std::chrono::microseconds; - lldb_private::LogIfAnyCategoriesSet( LIBLLDB_LOG_COMMUNICATION, "%p Communication::Read (dst = %p, dst_len = %" PRIu64 @@ -143,9 +141,7 @@ size_t Communication::Read(void *dst, size_t dst_len, listener_sp->StartListeningForEvents( this, eBroadcastBitReadThreadGotBytes | eBroadcastBitReadThreadDidExit); EventSP event_sp; - microseconds listener_timeout = - timeout ? microseconds(*timeout) : microseconds(0); - while (listener_sp->WaitForEvent(listener_timeout, event_sp)) { + while (listener_sp->GetEvent(event_sp, timeout)) { const uint32_t event_type = event_sp->GetType(); if (event_type & eBroadcastBitReadThreadGotBytes) { return GetCachedBytes(dst, dst_len); @@ -386,7 +382,7 @@ void Communication::SynchronizeWithReadThread() { // Wait for the synchronization event. EventSP event_sp; - listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp); + listener_sp->GetEvent(event_sp, llvm::None); } void Communication::SetConnection(Connection *connection) { -- cgit v1.2.3