Ejemplo n.º 1
0
        public void enqueueData(object data_val)
        {
            //this->debug(false, "enqueueData", (char*)data_val);

            /* queue is too big */
            if ((this.MaxQueueLength != 0) && (this.QueueLength > this.MaxQueueLength))
            {
                //phwangFree(data_val, "QueueClass::enqueueData");
                //this->abend("enqueueData", "queue full");
                return;
            }

            QueueEntryClass entry = new QueueEntryClass();

            if (entry == null)
            {
                //this->abend("enqueueData", "fail to create new QueueEntryClass");
                return;
            }
            entry.data = data_val;

            this.AbendQueue("enqueueData begin");
            lock (this.Lock)
            {
                this.EnqueueEntry(entry);
            }

            this.AbendQueue("enqueueData end");

            //if (this->theSuspendObject)
            {
                //this->theSuspendObject->signal();
            }
        }
Ejemplo n.º 2
0
        private QueueEntryClass dequeueEntry()
        {
            QueueEntryClass entry;

            if (this.QueueLength == 0)
            {
                //this->abend("dequeueEntry", "theQueueSize == 0");
                return(null);
            }

            if (this.QueueLength == 1)
            {
                entry            = this.QueueHead;
                this.QueueHead   = this.QueueTail = null;
                this.QueueLength = 0;
                return(entry);
            }

            entry               = this.QueueHead;
            this.QueueHead      = this.QueueHead.next;
            this.QueueHead.prev = null;
            this.QueueLength--;

            return(entry);
        }
Ejemplo n.º 3
0
 private void EnqueueEntry(QueueEntryClass entry)
 {
     if (this.QueueHead == null)
     {
         entry.next       = null;
         entry.prev       = null;
         this.QueueHead   = entry;
         this.QueueTail   = entry;
         this.QueueLength = 1;
     }
     else
     {
         entry.next          = null;
         entry.prev          = this.QueueTail;
         this.QueueTail.next = entry;
         this.QueueTail      = entry;
         this.QueueLength++;
     }
 }
Ejemplo n.º 4
0
        private void FlushQueue()
        {
            QueueEntryClass entry, entry_next;

            //pthread_mutex_lock(&this->theMutex);
            entry = this.QueueHead;
            while (entry != null)
            {
                entry_next = entry.next;
                //phwangFree(entry->data, "QueueClass::flushQueue");
                //delete entry;
                this.QueueLength--;
                entry = entry_next;
            }
            this.QueueHead = this.QueueTail = null;

            if (this.QueueLength != 0)
            {
                //this->abend("flushQueue", "theQueueSize");
            }

            //pthread_mutex_unlock(&this->theMutex);
        }