Ejemplo n.º 1
0
MessageQueue::MessageQueue(const char* name)
   : _queueId(getNextQueueId())
{
    //
    // Copy the name:
    //

    PEG_METHOD_ENTER(TRC_MESSAGEQUEUESERVICE,"MessageQueue::MessageQueue()");

    if (!name)
    {
        name = "";
    }

    _name = new char[strlen(name) + 1];
    strcpy(_name, name);

    PEG_TRACE((TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL3,
        "MessageQueue::MessageQueue  name = %s, queueId = %u", name, _queueId));

    //
    // Insert into queue table:
    //
    AutoMutex autoMut(q_table_mut);
    while (!_queueTable.insert(_queueId, this))
        ;

    PEG_METHOD_EXIT();
}
Ejemplo n.º 2
0
MessageQueue::MessageQueue(
    const char* name,
    Boolean async,
    Uint32 queueId)
   : _queueId(queueId), _capabilities(0), _count(0), _front(0), _back(0), _async(async)
{
    //
    // Copy the name:
    //

    PEG_METHOD_ENTER(TRC_MESSAGEQUEUESERVICE,"MessageQueue::MessageQueue()");

    if (!name)
        name = "";

    _name = new char[strlen(name) + 1];
    strcpy(_name, name);

    Tracer::trace(TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL3,
        "MessageQueue::MessageQueue  name = %s, queueId = %u", name, queueId);

    //
    // Insert into queue table:
    //
    AutoMutex autoMut(q_table_mut);
    while (!_queueTable.insert(_queueId, this))
        ;

    PEG_METHOD_EXIT();
}
Ejemplo n.º 3
0
MessageQueue::~MessageQueue()
{
    // ATTN-A: thread safety!
    PEG_METHOD_ENTER(TRC_MESSAGEQUEUESERVICE,"MessageQueue::~MessageQueue()");
    Tracer::trace(TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL3,
        "MessageQueue::~MessageQueue queueId = %i, name = %s", _queueId, _name);

    {
        AutoMutex autoMut(q_table_mut);
        _queueTable.remove(_queueId);
    } // mutex unlocks here

    // Free the name:

    delete [] _name;

    while(_front)
    {
       Message* tmp = _front;
       _front = _front->_next;
       delete tmp;
    }

    PEG_METHOD_EXIT();
}
Ejemplo n.º 4
0
MessageQueue* MessageQueue::lookup(Uint32 queueId)
{

    MessageQueue* queue = 0;
    AutoMutex autoMut(q_table_mut);

    if (_queueTable.lookup(queueId, queue))
    {
        return queue;
    }

    // Not found!

    PEG_TRACE((TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL1,
        "MessageQueue::lookup failure queueId = %u", queueId));

    return 0;
}
Ejemplo n.º 5
0
MessageQueue* MessageQueue::lookup(const char *name)
{

    if (name == NULL)
        throw NullPointer();

    AutoMutex autoMut(q_table_mut);
    for (QueueTable::Iterator i = _queueTable.start(); i; i++)
    {
        // ATTN: Need to decide how many characters to compare in queue names
        if (!strcmp(((MessageQueue *)i.value())->getQueueName(), name))
        {
            return (MessageQueue *)i.value();
        }
    }

    PEG_TRACE((TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL1,
        "MessageQueue::lookup failure - name = %s", name));

    return 0;
}
Ejemplo n.º 6
0
MessageQueue::~MessageQueue()
{
    // ATTN-A: thread safety!
    PEG_METHOD_ENTER(TRC_MESSAGEQUEUESERVICE,"MessageQueue::~MessageQueue()");
    PEG_TRACE((TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL3,
        "MessageQueue::~MessageQueue queueId = %i, name = %s",
        _queueId,
        _name));

    {
        AutoMutex autoMut(q_table_mut);
        _queueTable.remove(_queueId);
    } // mutex unlocks here

    // Free the name:

    delete [] _name;

    // Return the queue id.

    putQueueId(_queueId);

    PEG_METHOD_EXIT();
}
Ejemplo n.º 7
0
void MessageQueue::remove_myself(Uint32 qid)
{
    AutoMutex autoMut(q_table_mut);
    _queueTable.remove(qid);
}