1 //===-- TimeoutResumeAll.h -------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_TARGET_TIMEOUTRESUMEALL_H 10 #define LLDB_TARGET_TIMEOUTRESUMEALL_H 11 12 #include "lldb/Target/ThreadPlanSingleThreadTimeout.h" 13 14 namespace lldb_private { 15 16 // Mixin class that provides the capability for ThreadPlan to support single 17 // thread execution that resumes all threads after a timeout. 18 // Opt-in thread plan should call PushNewTimeout() in its DidPush() and 19 // ResumeWithTimeout() during DoWillResume(). 20 class TimeoutResumeAll { 21 public: TimeoutResumeAll(Thread & thread)22 TimeoutResumeAll(Thread &thread) 23 : m_thread(thread), 24 m_timeout_info( 25 std::make_shared<ThreadPlanSingleThreadTimeout::TimeoutInfo>()) {} 26 PushNewTimeout()27 void PushNewTimeout() { 28 ThreadPlanSingleThreadTimeout::PushNewWithTimeout(m_thread, m_timeout_info); 29 } 30 ResumeWithTimeout()31 void ResumeWithTimeout() { 32 ThreadPlanSingleThreadTimeout::ResumeFromPrevState(m_thread, 33 m_timeout_info); 34 } 35 36 private: 37 Thread &m_thread; 38 ThreadPlanSingleThreadTimeout::TimeoutInfoSP m_timeout_info; 39 }; 40 41 } // namespace lldb_private 42 43 #endif // LLDB_TARGET_TIMEOUTRESUMEALL_H 44