// 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 {
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);
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<std::micro> &timeout);
- bool GetNextEventForBroadcaster(Broadcaster *broadcaster,
- lldb::EventSP &event_sp);
+ bool GetEventForBroadcaster(Broadcaster *broadcaster, lldb::EventSP &event_sp,
+ const Timeout<std::micro> &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<std::micro> &timeout);
size_t HandleBroadcastEvent(lldb::EventSP &event_sp);
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<std::micro> &timeout,
Broadcaster *broadcaster, // nullptr for any broadcaster
const ConstString *sources, // nullptr for any event
uint32_t num_sources, uint32_t event_type_mask,
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());
bool success = false;
if (m_opaque_sp) {
- std::chrono::microseconds timeout = std::chrono::microseconds(0);
+ Timeout<std::micro> 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;
}
const SBBroadcaster &broadcaster,
SBEvent &event) {
if (m_opaque_sp && broadcaster.IsValid()) {
- std::chrono::microseconds timeout = std::chrono::microseconds(0);
+ Timeout<std::micro> 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;
}
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<std::micro> 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;
}
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;
}
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;
}
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;
}
size_t Communication::Read(void *dst, size_t dst_len,
const Timeout<std::micro> &timeout,
ConnectionStatus &status, Error *error_ptr) {
- using std::chrono::microseconds;
-
lldb_private::LogIfAnyCategoriesSet(
LIBLLDB_LOG_COMMUNICATION,
"%p Communication::Read (dst = %p, dst_len = %" PRIu64
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);
// 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) {
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) {
// 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();
}
// 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();
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<std::mutex> 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<std::micro> &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<void *>(this),
- static_cast<unsigned long long>(timeout.count()),
+ log->Printf("%p Listener::GetEventInternal (timeout = %llu us) for %s",
+ static_cast<void *>(this), static_cast<unsigned long long>(
+ timeout ? timeout->count() : -1),
m_name.c_str());
std::unique_lock<std::mutex> lock(m_events_mutex);
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<void *>(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<void *>(this), m_name.c_str());
+ log->Printf("%p Listener::GetEventInternal() unknown error for %s",
+ static_cast<void *>(this), m_name.c_str());
return false;
}
}
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<std::micro> &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<std::micro> &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<std::micro> &timeout) {
+ return GetEventInternal(timeout, nullptr, nullptr, 0, 0, event_sp);
}
size_t Listener::HandleBroadcastEvent(EventSP &event_sp) {
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.");
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)
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<std::micro> 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
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;
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)
static_cast<unsigned long long>(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());
static_cast<unsigned long long>(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 {
// 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)) {
}
}
- 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 "
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) {
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 =
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");
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());
{
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());
}
using namespace lldb;
using namespace lldb_private;
-TEST(ListenerTest, GetNextEvent) {
+TEST(ListenerTest, GetEventImmediate) {
EventSP event_sp;
Broadcaster broadcaster(nullptr, "test-broadcaster");
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");
// 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);
// broadcast sends.
std::future<void> 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();
}
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);
}
};