22#include <sys/socket.h>
26namespace MultiProcess {
30constexpr std::uint64_t
moreBit = std::uint64_t(1) << 63;
42 static auto *
channels =
new std::vector<Channel *>;
62 return ::send(fd,
buf,
n, 0);
72 throw std::runtime_error(std::string(
"MultiProcess::Channel: could not set O_NONBLOCK: ") +
strerror(
errno));
92 out_buf_(std::move(
other.out_buf_)),
93 out_pos_(
other.out_pos_),
94 in_header_(
other.in_header_),
95 in_header_bytes_(
other.in_header_bytes_),
96 in_have_header_(
other.in_have_header_),
97 in_msg_(std::move(
other.in_msg_)),
98 in_msg_bytes_(
other.in_msg_bytes_)
109 if (
this != &
other) {
115 out_buf_ = std::move(
other.out_buf_);
116 out_pos_ =
other.out_pos_;
117 in_header_ =
other.in_header_;
118 in_header_bytes_ =
other.in_header_bytes_;
119 in_have_header_ =
other.in_have_header_;
120 in_msg_ = std::move(
other.in_msg_);
121 in_msg_bytes_ =
other.in_msg_bytes_;
149 ::poll(&
pfd, 1, 500);
153 throw ppoll_error_t(
EINTR,
"MultiProcess::Channel: connection closed while terminating");
155 throw std::runtime_error(
"MultiProcess::Channel: connection closed by peer process (did it die unexpectedly?)");
168 const char *
headerBytes =
reinterpret_cast<const char *
>(&header);
190 throw std::runtime_error(std::string(
"MultiProcess::Channel: send failed: ") +
strerror(
errno));
215 throw std::runtime_error(std::string(
"MultiProcess::Channel: receive failed: ") +
strerror(
errno));
239 throw std::runtime_error(std::string(
"MultiProcess::Channel: receive failed: ") +
strerror(
errno));
283 if (channel->has_pending_output()) {
306 throw std::runtime_error(std::string(
"MultiProcess::Channel::wait: poll failed: ") +
strerror(
errno));
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
std::string Message(const std::string &msg, const std::string &location)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
const_iterator begin() const
const_iterator end() const
One endpoint of a full-duplex interprocess message pipe.
std::size_t in_header_bytes_
void send_frame(const void *data, std::size_t size, bool more)
Queue one frame for sending and write out as much as the socket accepts.
static void throw_connection_closed()
Handle end-of-stream / closed-connection conditions; never returns.
bool try_recv_frame(Message &msg, bool *more)
Non-blocking receive attempt.
std::size_t in_msg_bytes_
static std::vector< std::size_t > wait(const std::vector< const Channel * > &read_channels, int timeout_ms)
Wait until at least one of read_channels has input available, flushing the pending output of all live...
Channel & operator=(const Channel &)=delete
bool try_flush()
Write out pending output; returns true when all of it has been written.
Message recv_frame(bool *more=nullptr)
Blocking receive of one complete frame, interruptible by SIGTERM (throws ppoll_error_t,...
std::vector< char > out_buf_
A contiguous byte buffer used as the unit of interprocess communication.
std::size_t size() const
Size of the message in bytes.
static bool sigterm_received()
static int sigterm_wake_fd()
Read end of the self-pipe that the SIGTERM handler writes to (or -1 on the master process,...
Thrown when a blocking wait on a Channel is interrupted, e.g.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...