CMS 3D CMS Logo

Public Member Functions | Private Attributes

evf::SlaveQueue Class Reference

#include <SlaveQueue.h>

List of all members.

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_.

                                       :
        queue_id_(0) {

        /* get an (existing) public message queue */
        queue_id_ = msgget(QUEUE_ID + ind, 0);
        if (queue_id_ == -1) {
                XCEPT_RAISE(evf::Exception, "failed to get message queue");
        }
}
SlaveQueue::~SlaveQueue ( )

Definition at line 15 of file SlaveQueue.cc.

                        {
}

Member Function Documentation

int SlaveQueue::id ( void  ) const

Definition at line 76 of file SlaveQueue.cc.

References queue_id_.

                         {
        return queue_id_;
}
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().

                                {
        int rc; /* error code retuend by system calls. */
        rc = msgsnd(queue_id_, ptr.ptr_, ptr.msize() + 1, 0);
        //      delete ptr;
        if (rc == -1)
                std::cout << "snd::Slave failed to post message - error:" << strerror(
                                errno) << std::endl;
        return rc;
}
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().

                                         {
        unsigned long msg_type = MSQS_MESSAGE_TYPE_SLA;
        int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, -msg_type, 0);
        if (rc == -1 && errno != ENOMSG) {
                std::string serr =
                                "rcv::Slave failed to get message from queue - error:";
                serr += strerror(errno);
                XCEPT_RAISE(evf::Exception, serr);
        } else if (rc == -1 && errno == ENOMSG)
                return MSGQ_MESSAGE_TYPE_RANGE;
        return msg_type;
}
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().

                                                    {
        unsigned long msg_type = MSQS_MESSAGE_TYPE_SLA;
        int rc =
                        msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, -msg_type, IPC_NOWAIT);
        if (rc == -1 && errno != ENOMSG) {
                std::string serr =
                                "rcvnb::Slave failed to get message from queue - error:";
                serr += strerror(errno);
                XCEPT_RAISE(evf::Exception, serr);
        } else if (rc == -1 && errno == ENOMSG)
                return MSGQ_MESSAGE_TYPE_RANGE;
        return msg_type;
}
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_.

                                                       {
        unsigned long msg_type = 0;
        int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, msg_type, IPC_NOWAIT);
        if (rc == -1 && errno != ENOMSG) {
                std::string serr =
                                "rcvnb::Slave failed to get message from queue - error:";
                serr += strerror(errno);
                XCEPT_RAISE(evf::Exception, serr);
        } else if (rc == -1 && errno == ENOMSG)
                return MSGQ_MESSAGE_TYPE_RANGE;
        return msg_type;
}
bool SlaveQueue::rcvQuiet ( MsgBuf ptr)

Definition at line 41 of file SlaveQueue.cc.

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

                                     {
        int rc = msgrcv(queue_id_, ptr.ptr_, ptr.msize() + 1, ptr->mtype, 0);
        if (rc == -1 && errno != ENOMSG) {
                return false;
        }
        return true;
}

Member Data Documentation

Definition at line 33 of file SlaveQueue.h.

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