ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
AthenaInterprocess::Process Class Reference

#include <Process.h>

Collaboration diagram for AthenaInterprocess::Process:

Public Member Functions

 Process (pid_t pid)
 
 Process (const Process &other)
 
Processoperator= (const Process &other)
 
virtual ~Process ()
 
pid_t getProcessID () const
 
bool connectIn (const SharedQueue &queue)
 
bool connectOut (const IdentifiedSharedQueue &queue)
 
bool schedule (const IMessageDecoder *func, const ScheduledWork *args)
 
int mainloop ATLAS_NOT_THREAD_SAFE ()
 

Static Public Member Functions

static Process launch ()
 

Private Attributes

SharedQueue m_inbox
 
IdentifiedSharedQueue m_outbox
 
pid_t m_pid
 

Detailed Description

Definition at line 17 of file Process.h.

Constructor & Destructor Documentation

◆ Process() [1/2]

AthenaInterprocess::Process::Process ( pid_t  pid)
explicit

Definition at line 34 of file Process.cxx.

34  : m_inbox(), m_outbox(), m_pid( pid )
35 {
36 
37 }

◆ Process() [2/2]

AthenaInterprocess::Process::Process ( const Process other)

Definition at line 39 of file Process.cxx.

39  :
40  m_inbox( other.m_inbox ), m_outbox( other.m_outbox ), m_pid( other.m_pid )
41 {
42 
43 }

◆ ~Process()

AthenaInterprocess::Process::~Process ( )
virtual

Definition at line 55 of file Process.cxx.

56 {
57 
58 }

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

int mainloop AthenaInterprocess::Process::ATLAS_NOT_THREAD_SAFE ( )

◆ connectIn()

bool AthenaInterprocess::Process::connectIn ( const SharedQueue queue)

Definition at line 67 of file Process.cxx.

68 {
69  if ( ! queue.name().empty() ) {
70  m_inbox = queue;
71  /* TODO: check that the queue is valid and can receive messages */
72  return true;
73  }
74 
75  return false;
76 }

◆ connectOut()

bool AthenaInterprocess::Process::connectOut ( const IdentifiedSharedQueue queue)

Definition at line 78 of file Process.cxx.

79 {
80  if ( ! queue.name().empty() ) {
81  m_outbox = queue;
82  /* TODO: check that the queue is valid and can send messages */
83  return true;
84  }
85 
86  return false;
87 }

◆ getProcessID()

pid_t AthenaInterprocess::Process::getProcessID ( ) const

Definition at line 62 of file Process.cxx.

63 {
64  return m_pid;
65 }

◆ launch()

Process AthenaInterprocess::Process::launch ( )
static

Definition at line 20 of file Process.cxx.

21 {
22  std::cout.flush();
23  std::cerr.flush();
24 
25  pid_t pid = fork();
26  if ( pid == 0 )
27  prctl( PR_SET_PDEATHSIG, SIGHUP ); // Linux only
28 
29  return Process(pid);
30 }

◆ operator=()

Process & AthenaInterprocess::Process::operator= ( const Process other)

Definition at line 45 of file Process.cxx.

46 {
47  if ( this != &other ) {
48  m_inbox = other.m_inbox;
49  m_outbox = other.m_outbox;
50  m_pid = other.m_pid;
51  }
52  return *this;
53 }

◆ schedule()

bool AthenaInterprocess::Process::schedule ( const IMessageDecoder func,
const ScheduledWork args 
)

Definition at line 89 of file Process.cxx.

90 {
91  //Send func
92  std::string strptr("");
93  if(func) {
94  size_t ptrsize = sizeof(func);
95  char* charptr = new char[ptrsize];
96  memcpy(charptr,&func,ptrsize);
97  strptr=std::string(charptr,ptrsize);
98  delete[] charptr;
99  }
100  bool send_ok = m_inbox.try_send(strptr);
101 
102  //Send params
103  if(send_ok) {
104  std::string strparam = (args?std::string((char*)args->data,args->size):std::string(""));
105  send_ok = m_inbox.try_send(strparam);
106  }
107 
108  return send_ok;
109 }

Member Data Documentation

◆ m_inbox

SharedQueue AthenaInterprocess::Process::m_inbox
private

Definition at line 36 of file Process.h.

◆ m_outbox

IdentifiedSharedQueue AthenaInterprocess::Process::m_outbox
private

Definition at line 37 of file Process.h.

◆ m_pid

pid_t AthenaInterprocess::Process::m_pid
private

Definition at line 38 of file Process.h.


The documentation for this class was generated from the following files:
pid_t
int32_t pid_t
Definition: FPGATrackSimTypes.h:19
AthenaInterprocess::Process::m_outbox
IdentifiedSharedQueue m_outbox
Definition: Process.h:37
AthenaInterprocess::Process::Process
Process(pid_t pid)
Definition: Process.cxx:34
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
AthenaInterprocess::Process::m_pid
pid_t m_pid
Definition: Process.h:38
beamspotman.queue
string queue
Definition: beamspotman.py:347
AthenaInterprocess::Process::m_inbox
SharedQueue m_inbox
Definition: Process.h:36
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
AthenaInterprocess::SharedQueue::try_send
virtual bool try_send(const std::string &)
Definition: SharedQueue.cxx:102
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80