-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannelUnixPipeImpl.h
More file actions
38 lines (35 loc) · 1.11 KB
/
ChannelUnixPipeImpl.h
File metadata and controls
38 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <expected>
#include <future>
#include <atomic>
#include <memory>
#include <thread>
#include "ChannelUnixFile.h"
namespace styxlib
{
class ChannelUnixPipeImpl : public ChannelUnixFile
{
public:
using StartResult = std::expected<ChannelUnixFile::FileDescriptorPair, ErrorCode>;
private:
std::thread serverThread;
std::atomic<bool> running{false};
std::atomic<bool> stopRequested{false};
std::unique_ptr<std::promise<StartResult>> startPromise;
FileDescriptorPair rxFds;
FileDescriptorPair txFds;
bool isDescriptorOwned{false};
private:
void workThreadFunction();
protected:
void closeDescriptors() override;
public:
ChannelUnixPipeImpl(const ChannelUnixFile::Configuration &config);
std::future<StartResult> start();
std::future<ErrorCode> connect(const FileDescriptorPair& fds);
bool isStarted() const;
bool isConnected() const;
std::future<void> stop();
FileDescriptorPair getClientFileDescriptors() const;
};
} // namespace styxlib