Audacity 3.2.0
BufferedIPCChannel.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file BufferedIPCChannel.h
6
7 @author Vitaly Sverchinsky
8
9 Part of lib-ipc library
10
11**********************************************************************/
12
13#pragma once
14
15#include <mutex>
16#include <condition_variable>
17#include <memory>
18#include <vector>
19#include <thread>
20
21#include "ipc-types.h"
22#include "IPCChannel.h"
23
25
30class BufferedIPCChannel final : public IPCChannel
31{
32 static constexpr int DefaultOutputBufferCapacity { 2048 };
33 static constexpr int DefaultInputBufferSize { 2048 };
34
35 bool mAlive {true};
36 std::mutex mSocketSync;
37 std::condition_variable mSendCondition;
38
39 std::unique_ptr<std::thread> mRecvRoutine;
40 std::unique_ptr<std::thread> mSendRoutine;
41
43
44 std::vector<char> mOutputBuffer;
45
46public:
47
49
53 ~BufferedIPCChannel() override;
54
58 void Send(const void* bytes, size_t length) override;
59
69};
Socket-based implementation of IPCChannel that uses intermediate buffer for data exchange between cli...
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 sending data from client to server or vice versa, complemented by IPCChannelStatusCallb...
Definition: IPCChannel.h:22
Interface for listening connection status changes.
Definition: IPCChannel.h:37
#define INVALID_SOCKET
Definition: ipc-types.h:28
#define SOCKET
Definition: ipc-types.h:30