21namespace MultiProcess {
56 for (std::size_t ix = 0; ix < process_manager.
N_workers(); ++ix) {
59 for (
auto &channel :
mw_) {
62 }
else if (process_manager.
is_queue()) {
65 for (std::size_t ix = 0; ix < process_manager.
N_workers(); ++ix) {
73 throw std::runtime_error(
"Messenger ctor: I'm neither master, nor queue, nor a worker");
108 handshake = receive_from_master_on_queue<X2X>();
112 handshake = receive_from_queue_on_master<X2X>();
116 handshake = receive_from_queue_on_worker<X2X>();
120 handshake = receive_from_worker_on_queue<X2X>(worker_id);
125 throw std::runtime_error(
"SIGTERM received in test_receive, aborting\n");
128 if (handshake != expected_ping_value) {
129 throw std::runtime_error(
130 "Messenger::test_connections: RECEIVE over connection failed, did not receive expected value!");
147 }
else if (process_manager.
is_queue()) {
149 std::size_t mq_index;
152 for (std::size_t ix = 0; ix < process_manager.
N_workers(); ++ix) {
159 std::vector<std::size_t> poll_result;
166 for (
auto readable_index : poll_result) {
168 if (readable_index == mq_index) {
173 auto this_worker_id = readable_index - 1;
184 }
else if (process_manager.
is_worker()) {
191 throw std::runtime_error(
"Messenger::test_connections: I'm neither master, nor queue, nor a worker");
200 for (
auto &channel :
qw_) {
203 return {std::move(poller), mq_index};
212 return {std::move(poller), mw_index};
227 for (std::size_t
index : readable) {
228 if (
index == candidate) {
230 return mw_[candidate];
235 throw std::logic_error(
"Messenger::select_worker_channel_on_master: poll returned no readable channels");
256#define PROCESS_VAL(p) \
257 case (p): s = #p; break;
264 default: s = std::to_string(
static_cast<int>(
value));
274 default: s = std::to_string(
static_cast<int>(
value));
285 default: s = std::to_string(
static_cast<int>(
value));
296 default: s = std::to_string(
static_cast<int>(
value));
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
One endpoint of a full-duplex interprocess message pipe.
std::vector< Channel > qw_
void test_receive(X2X expected_ping_value, test_rcv_pipes rcv_pipe, std::size_t worker_id)
Channel & select_worker_channel_on_master()
On master: pick the worker channel to receive the next message from.
void test_connections(const ProcessManager &process_manager)
Test whether the channels between all processes are working.
std::vector< Channel > mw_
std::pair< Poller, std::size_t > create_worker_poller()
Helper function that creates a poller for worker_loop()
Messenger(ProcessManager &process_manager)
void send_from_queue_to_master()
std::pair< Poller, std::size_t > create_queue_poller()
Helper function that creates a poller for Queue::loop()
void send_from_master_to_queue()
void update_worker_channel_on_master(Channel &channel, bool more)
void debug_print(std::string s)
Function called from send and receive template functions in debug builds used to monitor the messages...
std::size_t mw_next_poll_position_
Channel * mw_current_source_
void send_from_queue_to_worker(std::size_t this_worker_id)
void test_send(X2X ping_value, test_snd_pipes snd_pipe, std::size_t worker_id)
void send_from_worker_to_queue()
Waits for input on a set of registered Channels.
void unregister_channel(const Channel &channel)
std::vector< std::size_t > poll(int timeout_ms=-1) const
Wait for input; returns the registration indices of readable channels.
std::size_t register_channel(const Channel &channel)
Register a channel for input polling; returns its stable index.
Fork processes for queue and workers.
std::size_t N_workers() const
int claim_mw_fd(std::size_t worker_ix)
Hand over the master-worker channel end for the current process type.
static bool sigterm_received()
int claim_mq_fd()
Hand over the master-queue channel end for the current process type.
int claim_qw_fd(std::size_t worker_ix)
Hand over the queue-worker channel end for the current process type.
std::size_t worker_id() const
Thrown when a blocking wait on a Channel is interrupted, e.g.
std::ostream & operator<<(std::ostream &out, const Message &msg)
std::tuple< std::vector< std::size_t >, bool > careful_poll(Poller &poller)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...