(file) Return to MessageQueue.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/MessageQueue.cpp between version 1.15 and 1.16

version 1.15, 2001/12/27 21:20:53 version 1.16, 2001/12/28 17:15:37
Line 40 
Line 40 
 static QueueTable _queueTable(128); static QueueTable _queueTable(128);
 static Mutex q_table_mut = Mutex(); static Mutex q_table_mut = Mutex();
  
 static Uint32 _GetNextQueueId() throw(IPCException)  Uint32 MessageQueue::getNextQueueId() throw(IPCException)
 { {
      static Uint32 _nextQueueId = 1;
  
    static Uint32 _queueId = 2;     //
    static Mutex _id_mut = Mutex();     // Lock mutex:
      //
  
      static Mutex _id_mut = Mutex();
    _id_mut.lock(pegasus_thread_self());    _id_mut.lock(pegasus_thread_self());
  
    // Handle wrap-around!     // Assign next queue id. Handle wrap around and never assign zero as
    if (_queueId == 0)     // a queue id:
       _queueId = MessageQueue::_CIMOM_Q_ID;  
    Uint32 ret = _queueId++;  
    _id_mut.unlock();  
  
    return ret;     if (_nextQueueId == 0)
 }        _nextQueueId = 1;
  
 Uint32 MessageQueue::_CIMOM_Q_ID = 1;     Uint32 queueId = _nextQueueId++;
  
 MessageQueue::MessageQueue(const char * name, Boolean async)     //
         : _mut( ), _count(0), _front(0), _back(0),     // Unlock mutex:
           _async(async),     //
           _workThread(MessageQueue::workThread, this, false),  
           _workSemaphore(0)  
  
      _id_mut.unlock();
  
 {     return queueId;
    if(name != NULL)  
    {  
       strncpy(_name, name, 25);  
       _name[25] = 0x00;  
    }    }
    else  
       memset(_name, 0x00,25);  MessageQueue::MessageQueue(
       const char* name,
       Boolean async,
       Uint32 queueId)
       :
       _queueId(queueId), _count(0), _front(0), _back(0), _async(async),
       _workThread(MessageQueue::workThread, this, false), _workSemaphore(0)
   {
       //
       // Copy the name:
       //
   
       if (!name)
           name = "";
   
       _name = new char[strlen(name) + 1];
       strcpy(_name, name);
   
       //
       // Insert into queue table:
       //
  
     q_table_mut.lock(pegasus_thread_self());     q_table_mut.lock(pegasus_thread_self());
  
     while (!_queueTable.insert(_queueId = _GetNextQueueId(), this))      while (!_queueTable.insert(_queueId, this))
        ;        ;
   
     q_table_mut.unlock();     q_table_mut.unlock();
  
  
     if(_async == true)     if(_async == true)
     {  
        _workThread.run();        _workThread.run();
     }     }
  
 }  
   
 MessageQueue::~MessageQueue() MessageQueue::~MessageQueue()
 { {
     // ATTN-A: thread safety!     // ATTN-A: thread safety!
Line 104 
Line 117 
        _workThread.join();     // wait for thread to complete        _workThread.join();     // wait for thread to complete
     }     }
  
       // Free the name:
   
       delete [] _name;
 } }
  
  


Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2