本文整理汇总了C++中Timeout::count方法的典型用法代码示例。如果您正苦于以下问题:C++ Timeout::count方法的具体用法?C++ Timeout::count怎么用?C++ Timeout::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timeout
的用法示例。
在下文中一共展示了Timeout::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
size_t Communication::Read(void *dst, size_t dst_len,
const Timeout<std::micro> &timeout,
ConnectionStatus &status, Status *error_ptr) {
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION);
LLDB_LOG(
log,
"this = {0}, dst = {1}, dst_len = {2}, timeout = {3}, connection = {4}",
this, dst, dst_len, timeout, m_connection_sp.get());
if (m_read_thread_enabled) {
// We have a dedicated read thread that is getting data for us
size_t cached_bytes = GetCachedBytes(dst, dst_len);
if (cached_bytes > 0 || (timeout && timeout->count() == 0)) {
status = eConnectionStatusSuccess;
return cached_bytes;
}
if (!m_connection_sp) {
if (error_ptr)
error_ptr->SetErrorString("Invalid connection.");
status = eConnectionStatusNoConnection;
return 0;
}
ListenerSP listener_sp(Listener::MakeListener("Communication::Read"));
listener_sp->StartListeningForEvents(
this, eBroadcastBitReadThreadGotBytes | eBroadcastBitReadThreadDidExit);
EventSP 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);
}
if (event_type & eBroadcastBitReadThreadDidExit) {
if (GetCloseOnEOF())
Disconnect(nullptr);
break;
}
}
return 0;
}
// We aren't using a read thread, just read the data synchronously in this
// thread.
return ReadFromConnection(dst, dst_len, timeout, status, error_ptr);
}