25 #ifndef COMMON_UTILS_CHANNEL_HPP
26 #define COMMON_UTILS_CHANNEL_HPP
40 explicit Channel(
const bool closeOnExec =
true);
69 template<
typename Data>
75 template<
typename Data>
106 template<
typename Data>
109 assert(
mSocketIndex != -1 &&
"Channel's end isn't set");
114 template<
typename Data>
117 assert(
mSocketIndex != -1 &&
"Channel's end isn't set");
126 #endif // COMMON_UTILS_CHANNEL_HPP
int mSocketIndex
Definition: channel.hpp:102
void setLeft()
Use the "left" end of the channel Closes the "right" end.
Definition: channel.cpp:73
int getRightFD()
Gen the right file descriptor.
Definition: channel.cpp:107
int getLeftFD()
Gen the left file descriptor.
Definition: channel.cpp:102
void write(int fd, const void *bufferPtr, const size_t size, int timeoutMS)
Write to a file descriptor, throw on error.
Definition: fd-utils.cpp:208
int getFD()
Get an active file descriptor.
Definition: channel.cpp:96
void closeSocket(int socketIndex)
Definition: channel.cpp:119
~Channel()
Definition: channel.cpp:64
char data[368]
Definition: initctl.cpp:41
Channel & operator=(const Channel &)=delete
void setRight()
Use the "right" end of the channel Closes the "left" end.
Definition: channel.cpp:83
Channel(const bool closeOnExec=true)
Definition: channel.cpp:41
void shutdown()
Gracefully shutdown the used end of the channel.
Definition: channel.cpp:90
void setCloseOnExec(const bool closeOnExec)
Sets close on exec on an active fd to either true or false.
Definition: channel.cpp:112
Data read()
Receive data of a given type (size)
Definition: channel.hpp:115
Channel is implemented with a pair of anonymous sockets.
Definition: channel.hpp:38
std::array< int, 2 > mSockets
Definition: channel.hpp:103
void read(int fd, void *bufferPtr, const size_t size, int timeoutMS)
Read from a file descriptor, throw on error.
Definition: fd-utils.cpp:237
void write(const Data &data)
Send the data to the other end of the channel.
Definition: channel.hpp:107
File descriptor utility functions.