Audacity 3.2.0
|
Socket-based implementation of IPCChannel that uses intermediate buffer for data exchange between client and server. More...
#include <BufferedIPCChannel.h>
Public Member Functions | |
BufferedIPCChannel () | |
~BufferedIPCChannel () override | |
Destroys channel and stops any data exchange. More... | |
void | Send (const void *bytes, size_t length) override |
Thread-safe. More... | |
void | StartConversation (SOCKET socket, IPCChannelStatusCallback &callback) |
Allowed to be called only once during object lifetime. Takes ownership over a socket. Callback should be guaranteed to be alive between IPCChannelStatusCallback::OnConnect and IPCChannelStatusCallback::OnDisconnect, and will be accessed from multiple threads. More... | |
Public Member Functions inherited from IPCChannel | |
virtual | ~IPCChannel () |
virtual void | Send (const void *bytes, size_t length)=0 |
Write data to the channel. More... | |
Private Attributes | |
bool | mAlive {true} |
std::mutex | mSocketSync |
std::condition_variable | mSendCondition |
std::unique_ptr< std::thread > | mRecvRoutine |
std::unique_ptr< std::thread > | mSendRoutine |
SOCKET | mSocket {INVALID_SOCKET} |
std::vector< char > | mOutputBuffer |
Static Private Attributes | |
static constexpr int | DefaultOutputBufferCapacity { 2048 } |
static constexpr int | DefaultInputBufferSize { 2048 } |
Socket-based implementation of IPCChannel that uses intermediate buffer for data exchange between client and server.
Definition at line 30 of file BufferedIPCChannel.h.
BufferedIPCChannel::BufferedIPCChannel | ( | ) |
Definition at line 21 of file BufferedIPCChannel.cpp.
References DefaultOutputBufferCapacity, and mOutputBuffer.
|
override |
Destroys channel and stops any data exchange.
Definition at line 26 of file BufferedIPCChannel.cpp.
References CLOSE_SOCKET, INVALID_SOCKET, mRecvRoutine, mSendRoutine, and mSocket.
|
overridevirtual |
Thread-safe.
Implements IPCChannel.
Definition at line 47 of file BufferedIPCChannel.cpp.
References mOutputBuffer, mSendCondition, and mSocketSync.
void BufferedIPCChannel::StartConversation | ( | SOCKET | socket, |
IPCChannelStatusCallback & | callback | ||
) |
Allowed to be called only once during object lifetime. Takes ownership over a socket. Callback should be guaranteed to be alive between IPCChannelStatusCallback::OnConnect and IPCChannelStatusCallback::OnDisconnect, and will be accessed from multiple threads.
socket | A valid socket on which data exchange should happen |
callback | Used to send status updates |
Definition at line 63 of file BufferedIPCChannel.cpp.
References DefaultInputBufferSize, DefaultOutputBufferCapacity, INVALID_SOCKET, mAlive, mOutputBuffer, mRecvRoutine, mSendCondition, mSendRoutine, mSocket, mSocketSync, NFDS, IPCChannelStatusCallback::OnConnect(), IPCChannelStatusCallback::OnDataAvailable(), IPCChannelStatusCallback::OnDisconnect(), SOCKET_ERROR, and anonymous_namespace{NoteTrack.cpp}::swap().
|
staticconstexprprivate |
Definition at line 33 of file BufferedIPCChannel.h.
Referenced by StartConversation().
|
staticconstexprprivate |
Definition at line 32 of file BufferedIPCChannel.h.
Referenced by BufferedIPCChannel(), and StartConversation().
|
private |
Definition at line 35 of file BufferedIPCChannel.h.
Referenced by StartConversation().
|
private |
Definition at line 44 of file BufferedIPCChannel.h.
Referenced by BufferedIPCChannel(), Send(), and StartConversation().
|
private |
Definition at line 39 of file BufferedIPCChannel.h.
Referenced by StartConversation(), and ~BufferedIPCChannel().
|
private |
Definition at line 37 of file BufferedIPCChannel.h.
Referenced by Send(), and StartConversation().
|
private |
Definition at line 40 of file BufferedIPCChannel.h.
Referenced by StartConversation(), and ~BufferedIPCChannel().
|
private |
Definition at line 42 of file BufferedIPCChannel.h.
Referenced by StartConversation(), and ~BufferedIPCChannel().
|
private |
Definition at line 36 of file BufferedIPCChannel.h.
Referenced by Send(), and StartConversation().