12 #ifndef ROOT_TMPClient 13 #define ROOT_TMPClient 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::vector< pid_t > fWorkerPids
A vector containing the PIDs of children processes/workers.
bool Fork(TMPWorker &server)
This method forks the ROOT session into fNWorkers children processes.
TMonitor fMon
This object manages the sockets and detect socket events via TMonitor::Select.
unsigned GetNWorkers() const
This class works in conjuction with TMPClient, reacting to messages received from it as specified by ...
int MPSend(TSocket *s, unsigned code)
Send a message with the specified code on the specified socket.
~TMPClient()
Class destructor.
unsigned fNWorkers
The number of workers that should be spawned upon forking.
void Remove(TSocket *s)
Remove a certain socket from the monitor.
virtual void DeActivate(TSocket *sock)
De-activate a socket.
void DeActivate(TSocket *s)
DeActivate a certain socket.
void Error(const char *location, const char *msgfmt,...)
std::pair< unsigned, std::unique_ptr< TBufferFile > > MPCodeBufPair
An std::pair that wraps the code and optional object contained in a message.
TList * GetListOfActives() const
Returns a list with all active sockets.
TMPClient(unsigned nWorkers=0)
Class constructor.
bool fIsParent
This is true if this is the parent/client process, false if this is a child/worker process...
Base class for multiprocess applications' clients.
void SetNWorkers(unsigned n)
Set the number of workers that will be spawned by the next call to Fork()
void HandleMPCode(MPCodeBufPair &msg, TSocket *sender)
Handle messages containing an EMPCode.
virtual void ActivateAll()
Activate all de-activated sockets.
unsigned Broadcast(unsigned code, unsigned nMessages=0)
Send a message with the specified code to at most nMessages workers.
void ReapWorkers()
Wait on worker processes and remove their pids from fWorkerPids.
TMPClient & operator=(const TMPClient &)=delete