74 std::vector<char> secondaryOutputBuffer;
92 while(offset <
static_cast<int>(secondaryOutputBuffer.size()))
94 fd_set writefds, exceptfds;
99 auto ret = select(
NFDS(
mSocket),
nullptr, &writefds, &exceptfds,
nullptr);
105 secondaryOutputBuffer.data() + offset,
106 static_cast<int>(secondaryOutputBuffer.size()) - offset,
120 mRecvRoutine = std::make_unique<std::thread>([
this, &callback]{
125 auto terminate =
finally([
this, &callback]
144 fd_set readfds, exceptfds;
150 auto ret = select(
NFDS(
mSocket), &readfds,
nullptr, &exceptfds,
nullptr);
157 static_cast<int>(buffer.size()),
165 auto err = WSAGetLastError();
166 if(err != WSAEWOULDBLOCK && err != EAGAIN)
169 if(errno != EWOULDBLOCK && errno != EAGAIN)
std::condition_variable mSendCondition
void Send(const void *bytes, size_t length) override
Thread-safe.
std::vector< char > mOutputBuffer
static constexpr int DefaultOutputBufferCapacity
static constexpr int DefaultInputBufferSize
~BufferedIPCChannel() override
Destroys channel and stops any data exchange.
std::unique_ptr< std::thread > mSendRoutine
std::unique_ptr< std::thread > mRecvRoutine
void StartConversation(SOCKET socket, IPCChannelStatusCallback &callback)
Allowed to be called only once during object lifetime. Takes ownership over a socket....
Interface for listening connection status changes.
virtual void OnDataAvailable(const void *data, size_t size) noexcept=0
Called when data chunk received as a result of a preceding call to IPCChannel::Send....
virtual void OnDisconnect() noexcept=0
Invalidates IPCChannel passed as argument in OnConnect.
virtual void OnConnect(IPCChannel &channel) noexcept=0
Called when connection established.
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)