Author: labath Date: Thu May 3 08:33:41 2018 New Revision: 331458 URL: http://llvm.org/viewvc/llvm-project?rev=331458&view=rev Log: Remove the timed_out out-argument from Predicate::WaitForValueEqualTo
The function can only return in one of two ways: the Predicate value is successfully set within the allotted time, or it isn't (the wait times out). These states can be represented in the return value, and the extra arg adds no value. Modified: lldb/trunk/include/lldb/Core/Event.h lldb/trunk/include/lldb/Host/Predicate.h lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Core/Event.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Event.h?rev=331458&r1=331457&r2=331458&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Event.h (original) +++ lldb/trunk/include/lldb/Core/Event.h Thu May 3 08:33:41 2018 @@ -122,9 +122,8 @@ public: const ConstString &GetFlavor() const override { return GetFlavorString(); } bool WaitForEventReceived( - const std::chrono::microseconds &abstime = std::chrono::microseconds(0), - bool *timed_out = nullptr) { - return m_predicate.WaitForValueEqualTo(true, abstime, timed_out); + const std::chrono::microseconds &abstime = std::chrono::microseconds(0)) { + return m_predicate.WaitForValueEqualTo(true, abstime); } private: Modified: lldb/trunk/include/lldb/Host/Predicate.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Predicate.h?rev=331458&r1=331457&r2=331458&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Predicate.h (original) +++ lldb/trunk/include/lldb/Host/Predicate.h Thu May 3 08:33:41 2018 @@ -138,17 +138,12 @@ public: /// If non-nullptr, the absolute time at which we should stop /// waiting, else wait an infinite amount of time. /// - /// @param[out] timed_out - /// If not null, set to true if we return because of a time out, - /// and false if the value was set. - /// /// @return /// @li \b true if the \a m_value is equal to \a value - /// @li \b false otherwise + /// @li \b false otherwise (timeout occurred) //------------------------------------------------------------------ bool WaitForValueEqualTo(T value, const std::chrono::microseconds &timeout = - std::chrono::microseconds(0), - bool *timed_out = nullptr) { + std::chrono::microseconds(0)) { // pthread_cond_timedwait() or pthread_cond_wait() will atomically unlock // the mutex and wait for the condition to be set. When either function // returns, they will re-lock the mutex. We use an auto lock/unlock class @@ -160,19 +155,13 @@ public: printf("%s (value = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n", __FUNCTION__, value, timeout.count(), m_value); #endif - if (timed_out) - *timed_out = false; - while (m_value != value) { if (timeout == std::chrono::microseconds(0)) { m_condition.wait(lock); } else { std::cv_status result = m_condition.wait_for(lock, timeout); - if (result == std::cv_status::timeout) { - if (timed_out) - *timed_out = true; + if (result == std::cv_status::timeout) break; - } } } Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=331458&r1=331457&r2=331458&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Thu May 3 08:33:41 2018 @@ -536,18 +536,15 @@ Status Host::RunShellCommand(const Args error.SetErrorString("failed to get process ID"); if (error.Success()) { - bool timed_out = false; - shell_info_sp->process_reaped.WaitForValueEqualTo( - true, std::chrono::seconds(timeout_sec), &timed_out); - if (timed_out) { + if (!shell_info_sp->process_reaped.WaitForValueEqualTo( + true, std::chrono::seconds(timeout_sec))) { error.SetErrorString("timed out waiting for shell command to complete"); // Kill the process since it didn't complete within the timeout specified Kill(pid, SIGKILL); // Wait for the monitor callback to get the message - timed_out = false; shell_info_sp->process_reaped.WaitForValueEqualTo( - true, std::chrono::seconds(1), &timed_out); + true, std::chrono::seconds(1)); } else { if (status_ptr) *status_ptr = shell_info_sp->status; Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=331458&r1=331457&r2=331458&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Thu May 3 08:33:41 2018 @@ -175,7 +175,7 @@ bool CommunicationKDP::GetSequenceMutex( bool CommunicationKDP::WaitForNotRunningPrivate( const std::chrono::microseconds &timeout) { - return m_is_running.WaitForValueEqualTo(false, timeout, NULL); + return m_is_running.WaitForValueEqualTo(false, timeout); } size_t Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=331458&r1=331457&r2=331458&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu May 3 08:33:41 2018 @@ -3797,11 +3797,10 @@ void Process::ControlPrivateStateThread( bool receipt_received = false; if (PrivateStateThreadIsValid()) { while (!receipt_received) { - bool timed_out = false; // Check for a receipt for 2 seconds and then check if the private // state thread is still around. - receipt_received = event_receipt_sp->WaitForEventReceived( - std::chrono::seconds(2), &timed_out); + receipt_received = + event_receipt_sp->WaitForEventReceived(std::chrono::seconds(2)); if (!receipt_received) { // Check if the private state thread is still around. If it isn't // then we are done waiting _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits