コード例 #1
0
ファイル: Queue.cs プロジェクト: TashaDexter/DexStudy
 protected void OnQueueIsEmpty()
 {
     if (QueueIsEmpty != null)
     {
         QueueIsEmpty?.Invoke();
     }
 }
コード例 #2
0
        /// <summary>
        /// This is called from within the JobQueue and it has QueueModifyLock. Do not try to enqueue or dequeue anything or you risk deadlock.
        /// We can safely interrogate the queue because it is ModifyLocked. It might also be EnqueueLocked or DequeueLocked, but not both.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="newSize"></param>
        private void JobQueueQueueSizeChangedEvent(object sender, int newSize)
        {
            // QueueModifyLock is held, meaning the queue cannot be modified, therefore it's safe to
            // make decisions based on the size of the queue and it is safe to raise an event without the queue size changing during the event.
            if (newSize == 0)
            {
                QueueIsEmpty.Set();
            }
            else if (_oldSize == 0)
            {
                QueueIsEmpty.Reset();
            }

            // This event must not try to enqueue or dequeue anything in the JobQueue.
            QueueSizeChangedEvent?.Invoke(this, new SizeChangedEventArgs(_oldSize, newSize));
        }
コード例 #3
0
 protected virtual void OnQueueIsEmpty()
 {
     QueueIsEmpty?.Invoke(this, EventArgs.Empty);
 }