25 explicit TMPClient(
unsigned nWorkers = 0);
32 unsigned Broadcast(
unsigned code,
unsigned nMessages = 0);
33 template<
class T>
unsigned Broadcast(
unsigned code,
const std::vector<T> &objs);
34 template<
class T>
unsigned Broadcast(
unsigned code, std::initializer_list<T> &objs);
35 template<
class T>
unsigned Broadcast(
unsigned code, T obj,
unsigned nMessages = 0);
79 unsigned nArgs = args.size();
87 Error(
"TMPClient::Broadcast",
"[E] Could not send message to server\n");
102 std::vector<T> vargs(std::move(args));
130 if (count == nMessages)
136 Error(
"TMPClient::Broadcast",
"[E] Could not send message to server\n");
std::pair< unsigned, std::unique_ptr< TBufferFile > > MPCodeBufPair
An std::pair that wraps the code and optional object contained in a message.
int MPSend(TSocket *s, unsigned code)
Send a message with the specified code on the specified socket.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Base class for multiprocess applications' clients.
unsigned GetNWorkers() const
unsigned fNWorkers
The number of workers that should be spawned upon forking.
unsigned Broadcast(unsigned code, unsigned nMessages=0)
Send a message with the specified code to at most nMessages workers.
TMPClient & operator=(const TMPClient &)=delete
std::vector< pid_t > fWorkerPids
A vector containing the PIDs of children processes/workers.
~TMPClient()
Class destructor.
TMonitor fMon
This object manages the sockets and detect socket events via TMonitor::Select.
void HandleMPCode(MPCodeBufPair &msg, TSocket *sender)
Handle messages containing an EMPCode.
void ReapWorkers()
Wait on worker processes and remove their pids from fWorkerPids.
TMPClient(const TMPClient &)=delete
void SetNWorkers(unsigned n)
Set the number of workers that will be spawned by the next call to Fork()
void Remove(TSocket *s)
Remove a certain socket from the monitor.
bool Fork(TMPWorker &server)
This method forks the ROOT session into fNWorkers children processes.
bool fIsParent
This is true if this is the parent/client process, false if this is a child/worker process.
void DeActivate(TSocket *s)
DeActivate a certain socket.
This class works in conjuction with TMPClient, reacting to messages received from it as specified by ...
virtual void ActivateAll()
Activate all de-activated sockets.
virtual void DeActivate(TSocket *sock)
De-activate a socket.
TList * GetListOfActives() const
Returns a list with all active sockets.