9#ifndef LLDB_CORE_THREADEDCOMMUNICATION_H
10#define LLDB_CORE_THREADEDCOMMUNICATION_H
66 eBroadcastBitDisconnected =
68 eBroadcastBitReadThreadGotBytes =
70 eBroadcastBitReadThreadDidExit =
73 eBroadcastBitReadThreadShouldExit =
75 eBroadcastBitPacketAvailable =
77 eBroadcastBitNoMorePendingInput = (1u << 5),
100 void Clear()
override;
155 void SetConnection(std::unique_ptr<Connection> connection)
override;
210 void *callback_baton);
An event broadcasting class.
An abstract communications class.
Communication()
Construct the Communication object.
"lldb/Core/ThreadedCommunication.h" Variation of Communication that supports threaded reads.
llvm::StringRef GetBroadcasterClass() const override
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
virtual void AppendBytesToCache(const uint8_t *src, size_t src_len, bool broadcast, lldb::ConnectionStatus status)
Append new bytes that get read from the read thread into the internal object byte cache.
const ThreadedCommunication & operator=(const ThreadedCommunication &)=delete
size_t Read(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr) override
Read bytes from the current connection.
void SetConnection(std::unique_ptr< Connection > connection) override
Sets the connection that it to be used by this class.
std::recursive_mutex m_bytes_mutex
A mutex to protect multi-threaded access to the cached bytes.
HostThread m_read_thread
The read thread handle in case we need to cancel the thread.
~ThreadedCommunication() override
Destructor.
virtual bool StopReadThread(Status *error_ptr=nullptr)
Stops the read thread by cancelling it.
void SynchronizeWithReadThread()
Wait for the read thread to process all outstanding data.
std::atomic< bool > m_read_thread_did_exit
Whether the read thread is enabled.
lldb::ConnectionStatus m_pass_status
Connection status passthrough from read thread.
lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr) override
Disconnect the communications connection if one is currently connected.
std::mutex m_read_thread_mutex
void(* ReadThreadBytesReceived)(void *baton, const void *src, size_t src_len)
ReadThreadBytesReceived m_callback
Status m_pass_error
Error passthrough from read thread.
virtual bool StartReadThread(Status *error_ptr=nullptr)
Starts a read thread whose sole purpose it to read bytes from the current connection.
std::atomic< bool > m_read_thread_enabled
Whether the read thread is enabled.
static llvm::StringRef GetStaticBroadcasterClass()
virtual bool JoinReadThread(Status *error_ptr=nullptr)
std::string m_bytes
A buffer to cache bytes read in the ReadThread function.
size_t GetCachedBytes(void *dst, size_t dst_len)
Get any available bytes from our data cache.
bool ReadThreadIsRunning()
Checks if there is a currently running read thread.
lldb::thread_result_t ReadThread()
The read thread function.
std::mutex m_synchronize_mutex
ThreadedCommunication(const ThreadedCommunication &)=delete
void SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback, void *callback_baton)
A class that represents a running process on the host machine.
ConnectionStatus
Connection Status Types.