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)
 
bool rcvQuiet (MsgBuf &ptr)
 
 SlaveQueue (unsigned int ind)
 
 ~SlaveQueue ()
 

Private Attributes

int queue_id_
 

Detailed Description

Definition at line 17 of file SlaveQueue.h.

Constructor & Destructor Documentation

SlaveQueue::SlaveQueue ( unsigned int  ind)

Definition at line 5 of file SlaveQueue.cc.

References QUEUE_ID, and queue_id_.

5  :
6  queue_id_(0) {
7 
8  /* get an (existing) public message queue */
9  queue_id_ = msgget(QUEUE_ID + ind, 0);
10  if (queue_id_ == -1) {
11  XCEPT_RAISE(evf::Exception, "failed to get message queue");
12  }
13 }
#define QUEUE_ID
Definition: queue_defs.h:9
SlaveQueue::~SlaveQueue ( )

Definition at line 15 of file SlaveQueue.cc.

15  {
16 }

Member Function Documentation

int SlaveQueue::id ( void  ) const

Definition at line 76 of file SlaveQueue.cc.

References queue_id_.

76  {
77  return queue_id_;
78 }
int SlaveQueue::post ( MsgBuf ptr)

Definition at line 18 of file SlaveQueue.cc.

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

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

18  {
19  int rc; /* error code retuend by system calls. */
20  rc = msgsnd(queue_id_, ptr.ptr_, ptr.msize() + 1, 0);
21  // delete ptr;
22  if (rc == -1)
23  std::cout << "snd::Slave failed to post message - error:" << strerror(
24  errno) << std::endl;
25  return rc;
26 }
size_t msize()
Definition: MsgBuf.cc:33
struct msgbuf * ptr_
Definition: MsgBuf.h:24
tuple cout
Definition: gather_cfg.py:121
unsigned long SlaveQueue::rcv ( MsgBuf ptr)

Definition at line 28 of file SlaveQueue.cc.

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().

28  {
29  unsigned long msg_type = MSQS_MESSAGE_TYPE_SLA;
30  int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, -msg_type, 0);
31  if (rc == -1 && errno != ENOMSG) {
32  std::string serr =
33  "rcv::Slave failed to get message from queue - error:";
34  serr += strerror(errno);
35  XCEPT_RAISE(evf::Exception, serr);
36  } else if (rc == -1 && errno == ENOMSG)
38  return msg_type;
39 }
size_t msize()
Definition: MsgBuf.cc:33
#define MSQS_MESSAGE_TYPE_SLA
Definition: queue_defs.h:29
#define MSGQ_MESSAGE_TYPE_RANGE
Definition: queue_defs.h:13
struct msgbuf * ptr_
Definition: MsgBuf.h:24
unsigned long SlaveQueue::rcvNonBlocking ( MsgBuf ptr)

Definition at line 49 of file SlaveQueue.cc.

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

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

49  {
50  unsigned long msg_type = MSQS_MESSAGE_TYPE_SLA;
51  int rc =
52  msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, -msg_type, IPC_NOWAIT);
53  if (rc == -1 && errno != ENOMSG) {
54  std::string serr =
55  "rcvnb::Slave failed to get message from queue - error:";
56  serr += strerror(errno);
57  XCEPT_RAISE(evf::Exception, serr);
58  } else if (rc == -1 && errno == ENOMSG)
60  return msg_type;
61 }
size_t msize()
Definition: MsgBuf.cc:33
#define MSQS_MESSAGE_TYPE_SLA
Definition: queue_defs.h:29
#define MSGQ_MESSAGE_TYPE_RANGE
Definition: queue_defs.h:13
struct msgbuf * ptr_
Definition: MsgBuf.h:24
unsigned long SlaveQueue::rcvNonBlockingAny ( MsgBuf ptr)

Definition at line 63 of file SlaveQueue.cc.

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

63  {
64  unsigned long msg_type = 0;
65  int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, msg_type, IPC_NOWAIT);
66  if (rc == -1 && errno != ENOMSG) {
67  std::string serr =
68  "rcvnb::Slave failed to get message from queue - error:";
69  serr += strerror(errno);
70  XCEPT_RAISE(evf::Exception, serr);
71  } else if (rc == -1 && errno == ENOMSG)
73  return msg_type;
74 }
size_t msize()
Definition: MsgBuf.cc:33
#define MSGQ_MESSAGE_TYPE_RANGE
Definition: queue_defs.h:13
struct msgbuf * ptr_
Definition: MsgBuf.h:24
bool SlaveQueue::rcvQuiet ( MsgBuf ptr)

Definition at line 41 of file SlaveQueue.cc.

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

41  {
42  int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, ptr->mtype, 0);
43  if (rc == -1 && errno != ENOMSG) {
44  return false;
45  }
46  return true;
47 }
size_t msize()
Definition: MsgBuf.cc:33
struct msgbuf * ptr_
Definition: MsgBuf.h:24

Member Data Documentation

int evf::SlaveQueue::queue_id_
private

Definition at line 33 of file SlaveQueue.h.

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