CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
evf::SlaveQueue Class Reference

#include <SlaveQueue.h>

Public Member Functions

int id () const
 
int post (MsgBuf &ptr)
 
unsigned long rcv (MsgBuf &ptr)
 
unsigned long rcvNonBlocking (MsgBuf &ptr)
 
unsigned long rcvNonBlockingAny (MsgBuf &ptr)
 
 SlaveQueue (unsigned int ind)
 
 ~SlaveQueue ()
 

Private Attributes

int queue_id_
 

Detailed Description

Definition at line 18 of file SlaveQueue.h.

Constructor & Destructor Documentation

evf::SlaveQueue::SlaveQueue ( unsigned int  ind)
inline

Definition at line 22 of file SlaveQueue.h.

References QUEUE_ID, and queue_id_.

22  : queue_id_(0)
23  {
24 
25  /* get an (existing) public message queue */
26  queue_id_ = msgget(QUEUE_ID+ind, 0);
27  if (queue_id_ == -1) {
28  XCEPT_RAISE(evf::Exception, "failed to get message queue");
29  }
30  }
#define QUEUE_ID
Definition: queue_defs.h:9
evf::SlaveQueue::~SlaveQueue ( )
inline

Definition at line 31 of file SlaveQueue.h.

32  {
33  }

Member Function Documentation

int evf::SlaveQueue::id ( void  ) const
inline

Definition at line 84 of file SlaveQueue.h.

References queue_id_.

84 {return queue_id_;}
int evf::SlaveQueue::post ( MsgBuf ptr)
inline

Definition at line 35 of file SlaveQueue.h.

References gather_cfg::cout, evf::MsgBuf::msize(), evf::MsgBuf::ptr_, and queue_id_.

Referenced by evf::Vulture::control(), and evf::SubProcess::postSlave().

36  {
37  int rc; /* error code retuend by system calls. */
38  rc = msgsnd(queue_id_,ptr.ptr_, ptr.msize(),0);
39  // delete ptr;
40  if(rc==-1)
41  std::cout << "snd::Slave failed to post message - error:"
42  << strerror(errno) << std::endl;
43  return rc;
44  }
tuple cout
Definition: gather_cfg.py:41
unsigned long evf::SlaveQueue::rcv ( MsgBuf ptr)
inline

Definition at line 45 of file SlaveQueue.h.

References MSGQ_MESSAGE_TYPE_RANGE, evf::MsgBuf::msize(), MSQS_MESSAGE_TYPE_SLA, evf::MsgBuf::ptr_, and queue_id_.

Referenced by evf::Vulture::control(), and evf::SubProcess::rcvSlave().

46  {
47  unsigned long msg_type = MSQS_MESSAGE_TYPE_SLA;
48  int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize(), - msg_type, 0);
49  if (rc == -1 && errno != ENOMSG)
50  {
51  std::string serr = "rcv::Slave failed to get message from queue - error:";
52  serr += strerror(errno);
53  XCEPT_RAISE(evf::Exception, serr);
54  }
55  else if(rc == -1 && errno == ENOMSG) return MSGQ_MESSAGE_TYPE_RANGE;
56  return msg_type;
57  }
#define MSQS_MESSAGE_TYPE_SLA
Definition: queue_defs.h:27
#define MSGQ_MESSAGE_TYPE_RANGE
Definition: queue_defs.h:13
unsigned long evf::SlaveQueue::rcvNonBlocking ( MsgBuf ptr)
inline

Definition at line 58 of file SlaveQueue.h.

References MSGQ_MESSAGE_TYPE_RANGE, evf::MsgBuf::msize(), MSQS_MESSAGE_TYPE_SLA, evf::MsgBuf::ptr_, and queue_id_.

Referenced by evf::SubProcess::rcvSlaveNonBlocking().

59  {
60  unsigned long msg_type = MSQS_MESSAGE_TYPE_SLA;
61  int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize(), - msg_type, IPC_NOWAIT);
62  if (rc == -1 && errno != ENOMSG)
63  {
64  std::string serr = "rcvnb::Slave failed to get message from queue - error:";
65  serr += strerror(errno);
66  XCEPT_RAISE(evf::Exception, serr);
67  }
68  else if(rc == -1 && errno == ENOMSG) return MSGQ_MESSAGE_TYPE_RANGE;
69  return msg_type;
70  }
#define MSQS_MESSAGE_TYPE_SLA
Definition: queue_defs.h:27
#define MSGQ_MESSAGE_TYPE_RANGE
Definition: queue_defs.h:13
unsigned long evf::SlaveQueue::rcvNonBlockingAny ( MsgBuf ptr)
inline

Definition at line 71 of file SlaveQueue.h.

References MSGQ_MESSAGE_TYPE_RANGE, evf::MsgBuf::msize(), evf::MsgBuf::ptr_, and queue_id_.

72  {
73  unsigned long msg_type = 0;
74  int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize(), msg_type, IPC_NOWAIT);
75  if (rc == -1 && errno != ENOMSG)
76  {
77  std::string serr = "rcvnb::Slave failed to get message from queue - error:";
78  serr += strerror(errno);
79  XCEPT_RAISE(evf::Exception, serr);
80  }
81  else if(rc == -1 && errno == ENOMSG) return MSGQ_MESSAGE_TYPE_RANGE;
82  return msg_type;
83  }
#define MSGQ_MESSAGE_TYPE_RANGE
Definition: queue_defs.h:13

Member Data Documentation

int evf::SlaveQueue::queue_id_
private

Definition at line 87 of file SlaveQueue.h.

Referenced by id(), post(), rcv(), rcvNonBlocking(), rcvNonBlockingAny(), and SlaveQueue().