Index: lldb/trunk/include/lldb/Core/Listener.h =================================================================== --- lldb/trunk/include/lldb/Core/Listener.h +++ lldb/trunk/include/lldb/Core/Listener.h @@ -22,6 +22,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Event.h" +#include "lldb/Utility/Timeout.h" #include "lldb/lldb-private.h" namespace lldb_private { @@ -70,18 +71,6 @@ bool StopListeningForEvents(Broadcaster *broadcaster, uint32_t event_mask); - // Returns true if an event was received, false if we timed out. - bool WaitForEvent(const std::chrono::microseconds &timeout, - lldb::EventSP &event_sp); - - bool WaitForEventForBroadcaster(const std::chrono::microseconds &timeout, - Broadcaster *broadcaster, - lldb::EventSP &event_sp); - - bool WaitForEventForBroadcasterWithType( - const std::chrono::microseconds &timeout, Broadcaster *broadcaster, - uint32_t event_type_mask, lldb::EventSP &event_sp); - Event *PeekAtNextEvent(); Event *PeekAtNextEventForBroadcaster(Broadcaster *broadcaster); @@ -89,14 +78,16 @@ Event *PeekAtNextEventForBroadcasterWithType(Broadcaster *broadcaster, uint32_t event_type_mask); - bool GetNextEvent(lldb::EventSP &event_sp); + // Returns true if an event was received, false if we timed out. + bool GetEvent(lldb::EventSP &event_sp, const Timeout &timeout); - bool GetNextEventForBroadcaster(Broadcaster *broadcaster, - lldb::EventSP &event_sp); + bool GetEventForBroadcaster(Broadcaster *broadcaster, lldb::EventSP &event_sp, + const Timeout &timeout); - bool GetNextEventForBroadcasterWithType(Broadcaster *broadcaster, - uint32_t event_type_mask, - lldb::EventSP &event_sp); + bool GetEventForBroadcasterWithType(Broadcaster *broadcaster, + uint32_t event_type_mask, + lldb::EventSP &event_sp, + const Timeout &timeout); size_t HandleBroadcastEvent(lldb::EventSP &event_sp); @@ -128,14 +119,7 @@ uint32_t num_sources, uint32_t event_type_mask, lldb::EventSP &event_sp, bool remove); - bool - GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster - const ConstString *sources, // nullptr for any event - uint32_t num_sources, uint32_t event_type_mask, - lldb::EventSP &event_sp); - - bool - WaitForEventsInternal(const std::chrono::microseconds &timeout, + bool GetEventInternal(const Timeout &timeout, Broadcaster *broadcaster, // nullptr for any broadcaster const ConstString *sources, // nullptr for any event uint32_t num_sources, uint32_t event_type_mask, Index: lldb/trunk/source/API/SBDebugger.cpp =================================================================== --- lldb/trunk/source/API/SBDebugger.cpp +++ lldb/trunk/source/API/SBDebugger.cpp @@ -368,8 +368,8 @@ if (process_sp) { EventSP event_sp; ListenerSP lldb_listener_sp = m_opaque_sp->GetListener(); - while (lldb_listener_sp->GetNextEventForBroadcaster(process_sp.get(), - event_sp)) { + while (lldb_listener_sp->GetEventForBroadcaster( + process_sp.get(), event_sp, std::chrono::seconds(0))) { SBEvent event(event_sp); HandleProcessEvent(process, event, GetOutputFileHandle(), GetErrorFileHandle()); Index: lldb/trunk/source/API/SBListener.cpp =================================================================== --- lldb/trunk/source/API/SBListener.cpp +++ lldb/trunk/source/API/SBListener.cpp @@ -156,14 +156,14 @@ bool success = false; if (m_opaque_sp) { - std::chrono::microseconds timeout = std::chrono::microseconds(0); + Timeout timeout(llvm::None); if (timeout_secs != UINT32_MAX) { assert(timeout_secs != 0); // Take this out after all calls with timeout // set to zero have been removed.... timeout = std::chrono::seconds(timeout_secs); } EventSP event_sp; - if (m_opaque_sp->WaitForEvent(timeout, event_sp)) { + if (m_opaque_sp->GetEvent(event_sp, timeout)) { event.reset(event_sp); success = true; } @@ -191,12 +191,12 @@ const SBBroadcaster &broadcaster, SBEvent &event) { if (m_opaque_sp && broadcaster.IsValid()) { - std::chrono::microseconds timeout = std::chrono::microseconds(0); + Timeout timeout(llvm::None); if (num_seconds != UINT32_MAX) timeout = std::chrono::seconds(num_seconds); EventSP event_sp; - if (m_opaque_sp->WaitForEventForBroadcaster(timeout, broadcaster.get(), - event_sp)) { + if (m_opaque_sp->GetEventForBroadcaster(broadcaster.get(), event_sp, + timeout)) { event.reset(event_sp); return true; } @@ -209,12 +209,12 @@ uint32_t num_seconds, const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { if (m_opaque_sp && broadcaster.IsValid()) { - std::chrono::microseconds timeout = std::chrono::microseconds(0); + Timeout timeout(llvm::None); if (num_seconds != UINT32_MAX) timeout = std::chrono::seconds(num_seconds); EventSP event_sp; - if (m_opaque_sp->WaitForEventForBroadcasterWithType( - timeout, broadcaster.get(), event_type_mask, event_sp)) { + if (m_opaque_sp->GetEventForBroadcasterWithType( + broadcaster.get(), event_type_mask, event_sp, timeout)) { event.reset(event_sp); return true; } @@ -257,7 +257,7 @@ bool SBListener::GetNextEvent(SBEvent &event) { if (m_opaque_sp) { EventSP event_sp; - if (m_opaque_sp->GetNextEvent(event_sp)) { + if (m_opaque_sp->GetEvent(event_sp, std::chrono::seconds(0))) { event.reset(event_sp); return true; } @@ -270,7 +270,8 @@ SBEvent &event) { if (m_opaque_sp && broadcaster.IsValid()) { EventSP event_sp; - if (m_opaque_sp->GetNextEventForBroadcaster(broadcaster.get(), event_sp)) { + if (m_opaque_sp->GetEventForBroadcaster(broadcaster.get(), event_sp, + std::chrono::seconds(0))) { event.reset(event_sp); return true; } @@ -284,8 +285,9 @@ SBEvent &event) { if (m_opaque_sp && broadcaster.IsValid()) { EventSP event_sp; - if (m_opaque_sp->GetNextEventForBroadcasterWithType( - broadcaster.get(), event_type_mask, event_sp)) { + if (m_opaque_sp->GetEventForBroadcasterWithType(broadcaster.get(), + event_type_mask, event_sp, + std::chrono::seconds(0))) { event.reset(event_sp); return true; } Index: lldb/trunk/source/Core/Communication.cpp =================================================================== --- lldb/trunk/source/Core/Communication.cpp +++ lldb/trunk/source/Core/Communication.cpp @@ -115,8 +115,6 @@ 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 @@ 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 @@ // 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) { Index: lldb/trunk/source/Core/Debugger.cpp =================================================================== --- lldb/trunk/source/Core/Debugger.cpp +++ lldb/trunk/source/Core/Debugger.cpp @@ -1535,7 +1535,7 @@ bool done = false; while (!done) { EventSP event_sp; - if (listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp)) { + if (listener_sp->GetEvent(event_sp, llvm::None)) { if (event_sp) { Broadcaster *broadcaster = event_sp->GetBroadcaster(); if (broadcaster) { @@ -1616,7 +1616,7 @@ // to wait an infinite amount of time for it (nullptr timeout as the first // parameter) lldb::EventSP event_sp; - listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp); + listener_sp->GetEvent(event_sp, llvm::None); } return m_event_handler_thread.IsJoinable(); } Index: lldb/trunk/source/Core/IOHandler.cpp =================================================================== --- lldb/trunk/source/Core/IOHandler.cpp +++ lldb/trunk/source/Core/IOHandler.cpp @@ -1847,7 +1847,7 @@ // Just a timeout from using halfdelay(), check for events EventSP event_sp; while (listener_sp->PeekAtNextEvent()) { - listener_sp->GetNextEvent(event_sp); + listener_sp->GetEvent(event_sp, std::chrono::seconds(0)); if (event_sp) { Broadcaster *broadcaster = event_sp->GetBroadcaster(); Index: lldb/trunk/source/Core/Listener.cpp =================================================================== --- lldb/trunk/source/Core/Listener.cpp +++ lldb/trunk/source/Core/Listener.cpp @@ -345,44 +345,17 @@ return nullptr; } -bool Listener::GetNextEventInternal( - Broadcaster *broadcaster, // nullptr for any broadcaster - const ConstString *broadcaster_names, // nullptr for any event - uint32_t num_broadcaster_names, uint32_t event_type_mask, - EventSP &event_sp) { - std::unique_lock guard(m_events_mutex); - return FindNextEventInternal(guard, broadcaster, broadcaster_names, - num_broadcaster_names, event_type_mask, event_sp, - true); -} - -bool Listener::GetNextEvent(EventSP &event_sp) { - return GetNextEventInternal(nullptr, nullptr, 0, 0, event_sp); -} - -bool Listener::GetNextEventForBroadcaster(Broadcaster *broadcaster, - EventSP &event_sp) { - return GetNextEventInternal(broadcaster, nullptr, 0, 0, event_sp); -} - -bool Listener::GetNextEventForBroadcasterWithType(Broadcaster *broadcaster, - uint32_t event_type_mask, - EventSP &event_sp) { - return GetNextEventInternal(broadcaster, nullptr, 0, event_type_mask, - event_sp); -} - -bool Listener::WaitForEventsInternal( - const std::chrono::microseconds &timeout, +bool Listener::GetEventInternal( + const Timeout &timeout, Broadcaster *broadcaster, // nullptr for any broadcaster const ConstString *broadcaster_names, // nullptr for any event uint32_t num_broadcaster_names, uint32_t event_type_mask, EventSP &event_sp) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS)); if (log != nullptr) - log->Printf("%p Listener::WaitForEventsInternal (timeout = %llu us) for %s", - static_cast(this), - static_cast(timeout.count()), + log->Printf("%p Listener::GetEventInternal (timeout = %llu us) for %s", + static_cast(this), static_cast( + timeout ? timeout->count() : -1), m_name.c_str()); std::unique_lock lock(m_events_mutex); @@ -394,23 +367,22 @@ return true; } else { std::cv_status result = std::cv_status::no_timeout; - if (timeout == std::chrono::microseconds(0)) + if (!timeout) m_events_condition.wait(lock); else - result = m_events_condition.wait_for(lock, timeout); + result = m_events_condition.wait_for(lock, *timeout); if (result == std::cv_status::timeout) { log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS); if (log) - log->Printf("%p Listener::WaitForEventsInternal() timed out for %s", + log->Printf("%p Listener::GetEventInternal() timed out for %s", static_cast(this), m_name.c_str()); return false; } else if (result != std::cv_status::no_timeout) { log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS); if (log) - log->Printf( - "%p Listener::WaitForEventsInternal() unknown error for %s", - static_cast(this), m_name.c_str()); + log->Printf("%p Listener::GetEventInternal() unknown error for %s", + static_cast(this), m_name.c_str()); return false; } } @@ -419,22 +391,21 @@ return false; } -bool Listener::WaitForEventForBroadcasterWithType( - const std::chrono::microseconds &timeout, Broadcaster *broadcaster, - uint32_t event_type_mask, EventSP &event_sp) { - return WaitForEventsInternal(timeout, broadcaster, nullptr, 0, - event_type_mask, event_sp); +bool Listener::GetEventForBroadcasterWithType( + Broadcaster *broadcaster, uint32_t event_type_mask, EventSP &event_sp, + const Timeout &timeout) { + return GetEventInternal(timeout, broadcaster, nullptr, 0, event_type_mask, + event_sp); } -bool Listener::WaitForEventForBroadcaster( - const std::chrono::microseconds &timeout, Broadcaster *broadcaster, - EventSP &event_sp) { - return WaitForEventsInternal(timeout, broadcaster, nullptr, 0, 0, event_sp); +bool Listener::GetEventForBroadcaster(Broadcaster *broadcaster, + EventSP &event_sp, + const Timeout &timeout) { + return GetEventInternal(timeout, broadcaster, nullptr, 0, 0, event_sp); } -bool Listener::WaitForEvent(const std::chrono::microseconds &timeout, - EventSP &event_sp) { - return WaitForEventsInternal(timeout, nullptr, nullptr, 0, 0, event_sp); +bool Listener::GetEvent(EventSP &event_sp, const Timeout &timeout) { + return GetEventInternal(timeout, nullptr, nullptr, 0, 0, event_sp); } size_t Listener::HandleBroadcastEvent(EventSP &event_sp) { Index: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1459,8 +1459,7 @@ new EventDataBytes(continue_packet.GetString().data(), continue_packet.GetSize())); - if (listener_sp->WaitForEvent(std::chrono::seconds(5), event_sp) == - false) { + if (listener_sp->GetEvent(event_sp, std::chrono::seconds(5)) == false) { error.SetErrorString("Resume timed out."); if (log) log->Printf("ProcessGDBRemote::DoResume: Resume timed out."); @@ -3534,8 +3533,7 @@ log->Printf("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID()); - if (process->m_async_listener_sp->WaitForEvent(std::chrono::microseconds(0), - event_sp)) { + if (process->m_async_listener_sp->GetEvent(event_sp, llvm::None)) { const uint32_t event_type = event_sp->GetType(); if (event_sp->BroadcasterIs(&process->m_async_broadcaster)) { if (log) Index: lldb/trunk/source/Target/Process.cpp =================================================================== --- lldb/trunk/source/Target/Process.cpp +++ lldb/trunk/source/Target/Process.cpp @@ -68,6 +68,15 @@ using namespace lldb; using namespace lldb_private; +// A temporary function to convert between old representations of timeouts (0 +// means infinite wait) and new Timeout class (0 means "poll"). +// TODO(labath): Fix up all callers and remove this. +static Timeout ConvertTimeout(std::chrono::microseconds t) { + if (t == std::chrono::microseconds(0)) + return llvm::None; + return t; +} + // Comment out line below to disable memory caching, overriding the process // setting // target.process.disable-memory-cache @@ -937,7 +946,9 @@ StateType Process::GetNextEvent(EventSP &event_sp) { StateType state = eStateInvalid; - if (m_listener_sp->GetNextEventForBroadcaster(this, event_sp) && event_sp) + if (m_listener_sp->GetEventForBroadcaster(this, event_sp, + std::chrono::seconds(0)) && + event_sp) state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); return state; @@ -1289,9 +1300,9 @@ listener_sp = m_listener_sp; StateType state = eStateInvalid; - if (listener_sp->WaitForEventForBroadcasterWithType( - timeout, this, eBroadcastBitStateChanged | eBroadcastBitInterrupt, - event_sp)) { + if (listener_sp->GetEventForBroadcasterWithType( + this, eBroadcastBitStateChanged | eBroadcastBitInterrupt, event_sp, + ConvertTimeout(timeout))) { if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged) state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); else if (log) @@ -1335,9 +1346,10 @@ static_cast(timeout.count())); StateType state = eStateInvalid; - if (m_private_state_listener_sp->WaitForEventForBroadcasterWithType( - timeout, &m_private_state_broadcaster, - eBroadcastBitStateChanged | eBroadcastBitInterrupt, event_sp)) + if (m_private_state_listener_sp->GetEventForBroadcasterWithType( + &m_private_state_broadcaster, + eBroadcastBitStateChanged | eBroadcastBitInterrupt, event_sp, + ConvertTimeout(timeout))) if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged) state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); @@ -1360,10 +1372,12 @@ static_cast(timeout.count())); if (control_only) - return m_private_state_listener_sp->WaitForEventForBroadcaster( - timeout, &m_private_state_control_broadcaster, event_sp); + return m_private_state_listener_sp->GetEventForBroadcaster( + &m_private_state_control_broadcaster, event_sp, + ConvertTimeout(timeout)); else - return m_private_state_listener_sp->WaitForEvent(timeout, event_sp); + return m_private_state_listener_sp->GetEvent(event_sp, + ConvertTimeout(timeout)); } bool Process::IsRunning() const { @@ -2881,7 +2895,7 @@ // Wait indefinitely for a stopped event since we just posted one above... lldb::EventSP event_sp; - listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp); + listener_sp->GetEvent(event_sp, llvm::None); StateType state = ProcessEventData::GetStateFromEvent(event_sp.get()); if (!StateIsStoppedState(state, false)) { @@ -5116,8 +5130,8 @@ } } - got_event = listener_sp->WaitForEvent(std::chrono::microseconds(500000), - event_sp); + got_event = + listener_sp->GetEvent(event_sp, std::chrono::milliseconds(500)); if (!got_event) { if (log) log->Printf("Process::RunThreadPlan(): didn't get any event after " @@ -5226,7 +5240,7 @@ got_event = false; } else #endif - got_event = listener_sp->WaitForEvent(timeout, event_sp); + got_event = listener_sp->GetEvent(event_sp, ConvertTimeout(timeout)); if (got_event) { if (event_sp) { @@ -5426,8 +5440,8 @@ if (log) log->PutCString("Process::RunThreadPlan(): Halt succeeded."); - got_event = listener_sp->WaitForEvent( - std::chrono::microseconds(500000), event_sp); + got_event = + listener_sp->GetEvent(event_sp, std::chrono::milliseconds(500)); if (got_event) { stop_state = Index: lldb/trunk/unittests/Core/BroadcasterTest.cpp =================================================================== --- lldb/trunk/unittests/Core/BroadcasterTest.cpp +++ lldb/trunk/unittests/Core/BroadcasterTest.cpp @@ -21,6 +21,7 @@ TEST(BroadcasterTest, BroadcastEvent) { EventSP event_sp; Broadcaster broadcaster(nullptr, "test-broadcaster"); + std::chrono::seconds timeout(0); // Create a listener, sign it up, make sure it recieves an event. ListenerSP listener1_sp = Listener::MakeListener("test-listener1"); @@ -28,7 +29,7 @@ EXPECT_EQ(event_mask1, listener1_sp->StartListeningForEvents(&broadcaster, event_mask1)); broadcaster.BroadcastEvent(event_mask1, nullptr); - EXPECT_TRUE(listener1_sp->GetNextEvent(event_sp)); + EXPECT_TRUE(listener1_sp->GetEvent(event_sp, timeout)); EXPECT_EQ(event_mask1, event_sp->GetType()); { @@ -38,20 +39,20 @@ EXPECT_EQ(event_mask2, listener2_sp->StartListeningForEvents( &broadcaster, event_mask1 | event_mask2)); broadcaster.BroadcastEvent(event_mask2, nullptr); - EXPECT_TRUE(listener2_sp->GetNextEvent(event_sp)); + EXPECT_TRUE(listener2_sp->GetEvent(event_sp, timeout)); EXPECT_EQ(event_mask2, event_sp->GetType()); // Both listeners should get this event. broadcaster.BroadcastEvent(event_mask1, nullptr); - EXPECT_TRUE(listener1_sp->GetNextEvent(event_sp)); + EXPECT_TRUE(listener1_sp->GetEvent(event_sp, timeout)); EXPECT_EQ(event_mask1, event_sp->GetType()); - EXPECT_TRUE(listener2_sp->GetNextEvent(event_sp)); + EXPECT_TRUE(listener2_sp->GetEvent(event_sp, timeout)); EXPECT_EQ(event_mask2, event_sp->GetType()); } // Now again only one listener should be active. broadcaster.BroadcastEvent(event_mask1, nullptr); - EXPECT_TRUE(listener1_sp->GetNextEvent(event_sp)); + EXPECT_TRUE(listener1_sp->GetEvent(event_sp, timeout)); EXPECT_EQ(event_mask1, event_sp->GetType()); } Index: lldb/trunk/unittests/Core/ListenerTest.cpp =================================================================== --- lldb/trunk/unittests/Core/ListenerTest.cpp +++ lldb/trunk/unittests/Core/ListenerTest.cpp @@ -17,7 +17,7 @@ using namespace lldb; using namespace lldb_private; -TEST(ListenerTest, GetNextEvent) { +TEST(ListenerTest, GetEventImmediate) { EventSP event_sp; Broadcaster broadcaster(nullptr, "test-broadcaster"); @@ -27,31 +27,34 @@ ASSERT_EQ(event_mask, listener_sp->StartListeningForEvents(&broadcaster, event_mask)); + const std::chrono::seconds timeout(0); // Without any events sent, these should return false. - EXPECT_FALSE(listener_sp->GetNextEvent(event_sp)); - EXPECT_FALSE(listener_sp->GetNextEventForBroadcaster(nullptr, event_sp)); - EXPECT_FALSE(listener_sp->GetNextEventForBroadcaster(&broadcaster, event_sp)); - EXPECT_FALSE(listener_sp->GetNextEventForBroadcasterWithType( - &broadcaster, event_mask, event_sp)); + EXPECT_FALSE(listener_sp->GetEvent(event_sp, timeout)); + EXPECT_FALSE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout)); + EXPECT_FALSE( + listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, timeout)); + EXPECT_FALSE(listener_sp->GetEventForBroadcasterWithType( + &broadcaster, event_mask, event_sp, timeout)); // Now send events and make sure they get it. broadcaster.BroadcastEvent(event_mask, nullptr); - EXPECT_TRUE(listener_sp->GetNextEvent(event_sp)); + EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout)); broadcaster.BroadcastEvent(event_mask, nullptr); - EXPECT_TRUE(listener_sp->GetNextEventForBroadcaster(nullptr, event_sp)); + EXPECT_TRUE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout)); broadcaster.BroadcastEvent(event_mask, nullptr); - EXPECT_TRUE(listener_sp->GetNextEventForBroadcaster(&broadcaster, event_sp)); + EXPECT_TRUE( + listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, timeout)); broadcaster.BroadcastEvent(event_mask, nullptr); - EXPECT_FALSE(listener_sp->GetNextEventForBroadcasterWithType( - &broadcaster, event_mask * 2, event_sp)); - EXPECT_TRUE(listener_sp->GetNextEventForBroadcasterWithType( - &broadcaster, event_mask, event_sp)); + EXPECT_FALSE(listener_sp->GetEventForBroadcasterWithType( + &broadcaster, event_mask * 2, event_sp, timeout)); + EXPECT_TRUE(listener_sp->GetEventForBroadcasterWithType( + &broadcaster, event_mask, event_sp, timeout)); } -TEST(ListenerTest, WaitForEvent) { +TEST(ListenerTest, GetEventWait) { EventSP event_sp; Broadcaster broadcaster(nullptr, "test-broadcaster"); @@ -63,33 +66,30 @@ // Without any events sent, these should make a short wait and return false. std::chrono::microseconds timeout(10); - EXPECT_FALSE(listener_sp->WaitForEvent(timeout, event_sp)); + EXPECT_FALSE(listener_sp->GetEvent(event_sp, timeout)); + EXPECT_FALSE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout)); EXPECT_FALSE( - listener_sp->WaitForEventForBroadcaster(timeout, nullptr, event_sp)); - EXPECT_FALSE( - listener_sp->WaitForEventForBroadcaster(timeout, &broadcaster, event_sp)); - EXPECT_FALSE(listener_sp->WaitForEventForBroadcasterWithType( - timeout, &broadcaster, event_mask, event_sp)); + listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, timeout)); + EXPECT_FALSE(listener_sp->GetEventForBroadcasterWithType( + &broadcaster, event_mask, event_sp, timeout)); // Now send events and make sure they get it. broadcaster.BroadcastEvent(event_mask, nullptr); - EXPECT_TRUE(listener_sp->WaitForEvent(timeout, event_sp)); + EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout)); broadcaster.BroadcastEvent(event_mask, nullptr); - EXPECT_TRUE( - listener_sp->WaitForEventForBroadcaster(timeout, nullptr, event_sp)); + EXPECT_TRUE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout)); broadcaster.BroadcastEvent(event_mask, nullptr); EXPECT_TRUE( - listener_sp->WaitForEventForBroadcaster(timeout, &broadcaster, event_sp)); + listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, timeout)); broadcaster.BroadcastEvent(event_mask, nullptr); - EXPECT_FALSE(listener_sp->WaitForEventForBroadcasterWithType( - timeout, &broadcaster, event_mask * 2, event_sp)); - EXPECT_TRUE(listener_sp->WaitForEventForBroadcasterWithType( - timeout, &broadcaster, event_mask, event_sp)); + EXPECT_FALSE(listener_sp->GetEventForBroadcasterWithType( + &broadcaster, event_mask * 2, event_sp, timeout)); + EXPECT_TRUE(listener_sp->GetEventForBroadcasterWithType( + &broadcaster, event_mask, event_sp, timeout)); - timeout = std::chrono::seconds(0); auto delayed_broadcast = [&] { std::this_thread::sleep_for(std::chrono::milliseconds(10)); broadcaster.BroadcastEvent(event_mask, nullptr); @@ -99,16 +99,16 @@ // broadcast sends. std::future async_broadcast = std::async(std::launch::async, delayed_broadcast); - EXPECT_TRUE(listener_sp->WaitForEvent(timeout, event_sp)); + EXPECT_TRUE(listener_sp->GetEvent(event_sp, llvm::None)); async_broadcast.get(); async_broadcast = std::async(std::launch::async, delayed_broadcast); EXPECT_TRUE( - listener_sp->WaitForEventForBroadcaster(timeout, &broadcaster, event_sp)); + listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, llvm::None)); async_broadcast.get(); async_broadcast = std::async(std::launch::async, delayed_broadcast); - EXPECT_TRUE(listener_sp->WaitForEventForBroadcasterWithType( - timeout, &broadcaster, event_mask, event_sp)); + EXPECT_TRUE(listener_sp->GetEventForBroadcasterWithType( + &broadcaster, event_mask, event_sp, llvm::None)); async_broadcast.get(); } Index: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp =================================================================== --- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp +++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp @@ -67,9 +67,8 @@ void WaitForRunEvent() { EventSP event_sp; - listener_sp->WaitForEventForBroadcasterWithType( - std::chrono::microseconds(0), &client, - TestClient::eBroadcastBitRunPacketSent, event_sp); + listener_sp->GetEventForBroadcasterWithType( + &client, TestClient::eBroadcastBitRunPacketSent, event_sp, llvm::None); } };