ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TMPWorker.h
Go to the documentation of this file.
1 /* @(#)root/multiproc:$Id$ */
2 // Author: Enrico Guiraud July 2015
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TMPWorker
13 #define ROOT_TMPWorker
14 
15 #include "TSysEvtHandler.h" //TFileHandler
16 #include "MPSendRecv.h" //MPCodeBufPair
17 #include <unistd.h> //pid_t
18 #include <memory> //unique_ptr
19 
20 class TMPWorker {
21  /// \cond
22  ClassDef(TMPWorker, 0);
23  /// \endcond
24 public:
25  TMPWorker();
26  virtual ~TMPWorker() {};
27  //it doesn't make sense to copy a TMPWorker (each one has a uniq_ptr to its socket)
28  TMPWorker(const TMPWorker &) = delete;
29  TMPWorker &operator=(const TMPWorker &) = delete;
30 
31  virtual void Init(int fd, unsigned workerN);
32  void Run();
33  TSocket *GetSocket() { return fS.get(); }
34  pid_t GetPid() { return fPid; }
35  unsigned GetNWorker() const { return fNWorker; }
36 
37 
38 private:
39  virtual void HandleInput(MPCodeBufPair &msg);
40 
41  std::unique_ptr<TSocket> fS; ///< This worker's socket. The unique_ptr makes sure resources are released.
42  pid_t fPid; ///< the PID of the process in which this worker is running
43  unsigned fNWorker; ///< the ordinal number of this worker (0 to nWorkers-1)
44 };
45 
46 #endif
pid_t GetPid()
Definition: TMPWorker.h:34
virtual void HandleInput(MPCodeBufPair &msg)
Handle a message with an EMPCode.
Definition: TMPWorker.cxx:88
pid_t fPid
the PID of the process in which this worker is running
Definition: TMPWorker.h:42
unsigned fNWorker
the ordinal number of this worker (0 to nWorkers-1)
Definition: TMPWorker.h:43
This class works in conjuction with TMPClient, reacting to messages received from it as specified by ...
Definition: TMPWorker.h:20
#define ClassDef(name, id)
Definition: Rtypes.h:254
unsigned GetNWorker() const
Definition: TMPWorker.h:35
std::unique_ptr< TSocket > fS
This worker's socket. The unique_ptr makes sure resources are released.
Definition: TMPWorker.h:41
TMPWorker()
Class constructor.
Definition: TMPWorker.cxx:42
TSocket * GetSocket()
Definition: TMPWorker.h:33
TMPWorker & operator=(const TMPWorker &)=delete
void Run()
Definition: TMPWorker.cxx:63
std::pair< unsigned, std::unique_ptr< TBufferFile >> MPCodeBufPair
An std::pair that wraps the code and optional object contained in a message.
Definition: MPSendRecv.h:20
virtual void Init(int fd, unsigned workerN)
This method is called by children processes right after forking.
Definition: TMPWorker.cxx:55
virtual ~TMPWorker()
Definition: TMPWorker.h:26