Пример #1
0
//=============================================================================
// METHOD: SPELLipcMessageMailbox::retrieve
//=============================================================================
SPELLipcMessage SPELLipcMessageMailbox::retrieve( std::string id, unsigned long timeoutMsec )
{
    DEBUG(NAME + "Retrieve response with id " + id)
    SPELLipcMessageQueue* queue = getQueue(id);

    SPELLipcMessage msg = VOID_MESSAGE;
    try
    {
    	if (timeoutMsec == 0)
    	{
    		msg = queue->pull();
    	}
    	else
    	{
    		msg = queue->pull(timeoutMsec);
    	}
        remove(id);
    }
    catch( SPELLqueueTimeout& timeout )
    {
        //remove(id);
        // Re-throw the exception
        throw SPELLipcError(NAME + "Response timed out (limit " + ISTR(timeoutMsec) + " msec.)", (SPELLerrorCode) IPC_ERROR_TIMEOUT_ECODE);
    }
    DEBUG(NAME + "Retrieve message with id " + id + " done: " + msg.getSequenceStr());
    return msg;
}
Пример #2
0
//=============================================================================
// METHOD: SPELLipcMessageMailbox::place
//=============================================================================
bool SPELLipcMessageMailbox::place( std::string id, const SPELLipcMessage& msg )
{
    DEBUG(NAME + "Place message on queue with id " + id + " (" + msg.getSequenceStr() + ")");
    SPELLipcMessageQueue* queue = getQueue(id);
    if(queue)
	{
        DEBUG(NAME + "Place message IN");
    	queue->push(msg);
        DEBUG(NAME + "Place message OUT");
    	return true;
	}
    else
    {
    	LOG_ERROR("###### No queue to place response " + msg.dataStr());
    	return false;
    }
}